mercredi 18 juillet 2018

Laravel Authorization doesn't work

I'm trying to hide a button and show it only to the admin, I think i writed the code well but still can't get the result i want, i can't see the button with the admin account neither with a normal user account

The FolderPolicy code

public function create(User $user)
{
    if($user->is_admin)
        return true;
}

the view

        @can('create')
            <a class="btn btn-primary" href="">New Folder</a>
        @endcan

i know there is other ways to get the result i want by checking direclty if the authenticated user is an admin, but i want to figure out why this one is not working. Thanks.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire