Friday, November 25, 2022

Livewire Authorization

 

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;

 
class EditPost extends \Livewire\Component
{
use AuthorizesRequests;
 
public $post;
 
public function mount(Post $post)
{
$this->post = $post;
}
 
public function save()
{
$this->authorize('update', $this->post);
 
$this->post->update(['title' => $this->title]);
}
}

No comments:

Post a Comment