Laravel 8 授权或抛出异常
2021-07-17 17:19 更新
如果要尝试对某个操作进行授权,并在未授权用户进行该操作的情况下抛出 illuminate\auth\access\authorizationexception,则可以使用 gate::authorize 方法。authorizationexception 的实例将自动转换为 403 http 响应:
Gate::authorize('update-post', $post);
// 当前行为已授权... 以上内容是否对您有帮助:

免费 AI IDE


更多建议: