Nesting of laravel Gate privilege association model

when using larave"s gate for permission verification
Admin_users (user table) Admin_roles (role table) Admin_permissions (permissions table) are many-to-many relationships

first, register gate in App/providers/AuthServiceProvider

$permissions=AdminPermission::all();
        foreach ($permissions as $permission){
            //$AdminUser
            Gate::define($permission->name,function($AdminUser) use ($permission){
                return $AdminUser->hasPermission($permission);
            });
        }

hasPermission () code in AdminUser.php

The
code indicates that relRole is the model association defined in AdminUser, the association to the Admin_ roses table
relPermission is the model association defined in AdminRole, and the association to the Admin_ permissions table
this code is a nested association of the model in order to obtain the permissions owned by the current user
    // 
    public function hasPermission($permission){
        //
        $allPermission=$this->with(["relRole.relPermission"])->find($this->id);
        dd($allPermission);
        return !! $allPermission->contains($permission);
    }

current problem:
I myself want to compare the full permissions of the user with the current permissions, but now there are two problems
1. Permissions are scattered under different role data.
2. When judging with the contains () method of a set, the prompt function does not exist because it is not a set itself.

attach the acquired $allPermision data

clipboard.png

according to the user getting all the permissions of the user, and judging whether the current permission is in the user"s authority, this business logic, how should I modify my code? thank you for correcting

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b32733-2be2d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b32733-2be2d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?