public function update(Request $request, Post $post)
{
$this->authorize('update', $post);
}
From my understanding, the second argument tells Laravel which Model is the 'update' permission about. In this case, $post (App\Models\Post) model. The confusing part for me is if the authorize() second exists only as a reference to the model or if does pass an Instance of the actual model, even if the 'update' method doesn't require it?
Example of update policy not requiring the actual $post instance:
public function update(User $user)
{
return $user->hasPermissionTo('update posts');
}
Example of update policy requiring the $post instance:
public function update(User $user, Post $post)
{
return $post->user_id === $user->id;
}
Would $this->authorize('update', $post) work for both examples even if in one case the update method requires only one argument and in another it requires two? What if it required three?