PHP code example of scuttlebyte / laravel-request-context
1. Go to this page and download the library: Download scuttlebyte/laravel-request-context library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
scuttlebyte / laravel-request-context example snippets
// store it
Context::put('currentTeam', Request::user()->teams->first());
// get it
$currentTeam = Context::get('currentTeam');
// store it
context('currentTeam', request()->user()->teams->first());
// get it
$currentTeam = context('currentTeam');
namespace App\Http\Middleware;
use Closure;
class StoreTeamRequestContext
{
public function handle($request, Closure $next)
{
$request->context()->put('currentTeam', $request->user()->teams()->first());
return $next($request);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.