Yeabsra Habtu
Yeabsra Habtu

Reputation: 1

Spatie \ Permission \ Exceptions \ PermissionDoesNotExist

I was trying to use spatie role and permission but when i try to update role and permission it gives me the above error and highlights the if statement in the function below located inside the user model

public static function roleHasPermissions($role,$permissions){

    $hasPermission=true;

    // dd($role);

    // dd($perm);

    foreach($permissions as $permission){

        if(!$role->hasPermissionTo($permission)){

            $hasPermission=true;

        }

    }

    return $hasPermission;

}

To update role and permission

Upvotes: 0

Views: 317

Answers (1)

Emmanuel Joshua
Emmanuel Joshua

Reputation: 94

The error simply implies that the permission you are checking for has not been created.

Check to ensure that the permission has been created before attempting to assign to a role.

Upvotes: 0

Related Questions