Policies: Model-Based Authorization
Attach policies to Eloquent models and use them in controllers.
What is a Policy?
A Policy is a class that organises authorization logic for a specific Eloquent model. Policies are recommended when you have multiple authorization actions for the same model.
Generating a Policy
Use Artisan to generate a policy. Add --model to pre-fill standard methods.
$ php artisan make:policy PostPolicy --model=PostAll lessons in this course
- Authentication with Laravel Breeze
- Protecting Routes with Middleware
- Gates: Simple Authorization Checks
- Policies: Model-Based Authorization