// in AuthServiceProvider's boot method
Gate::define('update-post', function (User $user, Post $post) {
return $user->id === $post->user_id;
});
//UpdatePostRequest.php
public function authorize()
{
return Gate::authorize('update',request()->post);
}
/**
* Create a new controller instance.
*
* @return void
*/
public function delete()
{
if (Gate::denies('isAdmin')) {
dd('You are not admin');
} else {
dd('Admin allowed');
}
}