[PHP] 浅谈 Laravel Authorization 的 gates 与 policies

首先要区分 Authentication 与 Authorization,认证和授权,粗细有别。

授权(Authorization) 有两种主要方式,Gates 和 Policies。

Gates 和 Policies 的定义可以类比 Routes 和 Controllers:

Gates 通过 回调函数 和 Class@method 两种方式定义用户的授权,Policies 通过 class 围绕模型定义授权逻辑。

Docs:https://laravel.com/docs/6.x/authorization

Link:https://www.cnblogs.com/farwish/p/11821670.html

原文地址:https://www.cnblogs.com/farwish/p/11821670.html