protected $middleware = [
\\App\\Http\\Middleware\\Syspoint::class,
]
use Session;
class Syspoint
{
echo \\Session::get(\'syspoint\');
}
dparoli's answer correct but not exactly! Because this middleware will run every web request!
How about running only under some route? Here is how;
protected $routeMiddleware = [
'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'sys-point' => \App\Http\Middleware\Syspoint::class,
];
Then on your route define new middleware
Route::group(['middleware' => ['web','sys-point'], 'namespace' => 'YourControllers'], function()
{
}