【发布时间】:2018-08-06 06:43:31
【问题描述】:
我能用这个做什么:
"传递给 App\Policies\NotePolicy::update() 的参数 1 必须是 App\Note 的实例,App\User 的实例给定,调用 /Users/acny/Desktop/project/vendor/laravel/framework/src/Illuminate/Auth/Access/Gate.php 在线481(查看:
enter code here/Users/acny/Desktop/project/resources/views/notes/edit.blade.php)"
NotePolicy.php
public function update(Note $note, User $user)
{
return $user->id == $note->user_id;
}
edit.blade.php(用于显示更新按钮):
@can('update', $note)
<button type="submit" class="btn btn-primary">Update Note</button>
@endcan
如果我在 edit.blade.php 中编写所有内容而不是“更新”,那么我没有错误,但这不是我想要的。
感谢您的帮助
【问题讨论】:
标签: laravel laravel-5.6