Laravel 5.5 Controller

Controller(控制器)

// 控制器中间件
Route::get('profile', 'UserController@show')->middleware('auth');

public function __construct()
{
    $this->middleware('token'); // 所有方法生效
    $this->middleware('auth')->only('show'); // 只对该方法生效
    $this->middleware('auth')->only(['show', 'index']); // 只对指定方法生效
    $this->middleware('auth')->except('show');  // 对该方法以外的方法生效
    $this->middleware('auth')->except(['show', 'index']);  // 对指定方法以外的方法生效
}

猜你喜欢

转载自blog.csdn.net/qq_37910492/article/details/84543312