Laravel Authorization Policies
January 16, 2026
•
1 min read
•
16 views
Table of Contents
Authorization with policies:
Create Policy
php artisan make:policy PostPolicy --model=Post
Policy Methods
class PostPolicy
{
public function update(User $user, Post $post): bool
{
return $user->id === $post->user_id;
}
public function delete(User $user, Post $post): bool
{
return $user->id === $post->user_id || $user->isAdmin();
}
}
Use in Controller
$this->authorize('update', $post);
Use in Blade
@can('update', $post)
@endcan
Related Posts
Laravel Sanctum API Authentication Complete Guide
Build secure API authentication with Laravel Sanctum for SPAs and mobile apps.
Laravel Rate Limiting: Protect Your Application
Implement rate limiting to protect your Laravel application from abuse.
Laravel Blade Components: Build Reusable UI
Create powerful reusable components with Laravel Blade.
Comments (0)
No comments yet. Be the first to comment!