php artisan make:middleware nameOfMiddleware
public function __construct()
{
/** middleware could be single string
* or array like this ['auth', 'admin']
* or clouser
*/
$this->middleware('middleware')
}
php artisan make:middleware <middleware-name>
<?php
namespace AppHttpMiddleware;
use Closure;
class BeforeMiddleware
{
public function handle($request, Closure $next)
{
// Perform action
return $next($request);
}
}
<?php
namespace AppHttpMiddleware;
use Closure;
class CheckType
{
public function handle($request, Closure $next)
{
// Perform action
return $next($request);
}
}