我已經創建一箇中間件可以說AuthenticateAdmin,並在Kernel.php我已經添加了代碼:如何使用中間件來要求中間件?
'auth_admin' => \App\Http\Middleware\AuthenticateAdmin::class,
在我的路線我有這樣的代碼:
Route::group(['middleware' => 'auth_admin'], function() {
// Admin routes here
});
在我AuthenticateAdmin。 PHP我有這樣的代碼」
<?php namespace App\Http\Middleware;
use Auth;
use Closure;
use Illuminate\Contracts\Auth\Guard;
class AuthenticateAdmin {
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
// Perform action here
return $next($request);
}
}
我想要做的是,每次我用中間件‘auth_admin’,之前的‘auth_admin’中間件去,我希望它爲PErF首先使用'auth'中間件。