最佳答案
only只是规定了create方法只有guest可以访问,已登录用户无权访问,没有规定其它的访问的权限。所以,store等方法未登录用户也都是可以访问的。
另外最终的权限在代码中是结合的吧?要求是除show/create/store方法外,其它方法都必须登录才能访问,其中create方法是只有未登录的才能访问,show/store方法是谁都可以访问。
$this->middleware('auth', [
'except' => ['show', 'create', 'store']
]);
$this->middleware('guest', [
'only' => ['create']
]);
讨论数量:
only只是规定了create方法只有guest可以访问,已登录用户无权访问,没有规定其它的访问的权限。所以,store等方法未登录用户也都是可以访问的。
另外最终的权限在代码中是结合的吧?要求是除show/create/store方法外,其它方法都必须登录才能访问,其中create方法是只有未登录的才能访问,show/store方法是谁都可以访问。
$this->middleware('auth', [
'except' => ['show', 'create', 'store']
]);
$this->middleware('guest', [
'only' => ['create']
]);
推荐文章: