lundi 10 juillet 2023

laravel gates permission foreach

excuse me, i'm a junior developer and im still learn about laravel gates concept. i have a tables structure like this.

  1. Users = id, email, password, role_id.

  2. role = id, name, description.

  3. permission = id, name, slug.

  4. role_permission = permission_id, role_id. and this is my code

    $permission = Permission::all();

     foreach($permission as $p){
         Gate::define($p->slug, function(User $user) use ($p) {
             return $user->role_id === ???;
         });
     }
    

My Code

what should i return to protect gates, thanks.

im still learning about laravel gates concept, so i hope the other senior developers help me to explain about gates



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/qvBZR0O
via IFTTT

Aucun commentaire:

Enregistrer un commentaire