Answer the question
In order to leave comments, you need to log in
How to set up automatic policies?
I register policy.
protected $policies = [
Role::class => RolePolicy::class,
User::class => UserPolicy::class,
ReferralRule::class => ReferralRulePolicy::class
];
use App\Models\ReferralRule;
use Packages\Admin\Models\User;
use Packages\Admin\Policies\ReferralRulePolicy;
use Packages\Admin\Policies\RolePolicy;
use Packages\Admin\Policies\UserPolicy;
$this->authorize('my permission', Model::class);
Answer the question
In order to leave comments, you need to log in
There is no such functionality. in the provider, a simple binding of the model to the policy is prescribed. It has nothing to do with controller methods. This is so that Laravel knows which policy to pull when you pass the model as an argument. The only way to not write the authorize helper everywhere is to specify the connection in the constructor of the resource controller
public function __construct()
{
$this->authorizeResource(Article::class, 'article');
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question