You're browsing the documentation for an old version of Livewire. Consider upgrading your project to Livewire 3.x.
Authorization
Introduction
To authorize actions in Livewire, you can use the AuthorizesRequests
trait in any component, then call $this->authorize()
like you normally would inside a controller. For example:
1use Illuminate\Foundation\Auth\Access\AuthorizesRequests; 2 3class EditPost extends \Livewire\Component 4{ 5 use AuthorizesRequests; 6 7 public $post; 8 9 public function mount(Post $post)10 {11 $this->post = $post;12 }13 14 public function save()15 {16 $this->authorize('update', $this->post);17 18 $this->post->update(['title' => $this->title]);19 }20}
If you use a different guard to authenticate your users then also add an entry to middleware_group in the livewire config file:
1...2'middleware_group' => ['web', 'auth:otherguard'],3...
← Previous Topic
Query String
Next Topic →
Pagination