0
votes

What can I do with this:

"Argument 1 passed to App\Policies\NotePolicy::update() must be an instance of App\Note, instance of App\User given, called in /Users/acny/Desktop/project/vendor/laravel/framework/src/Illuminate/Auth/Access/Gate.php on line 481 (View: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 (for show update button):

@can('update', $note)
        <button type="submit" class="btn btn-primary">Update Note</button>
@endcan

If I write every thing instead of 'update' in edit.blade.php then I have not error but that's not what I want.
thank for your help

1

1 Answers

0
votes

https://laravel.com/docs/5.6/authorization#writing-policies

Laravel passes the $user as the first argument. Switch your arguments around.