我通过此命令创建了一个策略并注册了该策略:
php artisan make:policy PostPolicy --model=Post
类中已包含更新策略方法:
public function update(User $user, Post $post)
{
return $user->id === $post->user_id;
}
现在我想使用@can指令:
@can('update', $post)
<!-- The Current User Can Update The Post -->
@endcan
但我收到此错误消息:&#34;未定义变量:post&#34;
https://laravel.com/docs/5.5/authorization#creating-policies