src/Users/User.php
public function permissions()
    {
        if ( ! isset($this->permissions) ) {
            $permissionModel = $this::$permissionModel;

            $this->permissions = $permissionModel::whereHas('roles', function ($query) {
                $query->whereHas('users', function ($query) {
                    $query->where('id', $this->id);
                });
            })->get();
        }

        return $this->permissions;
    }
public function permissions()
    {
        if ( ! isset($this->permissions) ) {
            $permissionModel = $this::$permissionModel;

            $this->permissions = $permissionModel::whereHas('roles', function ($query) {
                $query->whereHas('users', function ($query) {
                    $query->where('id', $this->id);
                });
            })->get();
        }

        return $this->permissions;
    }
public function permissions ( ) { if ( ! isset ( $ this -> permissions ) ) { $ permissionModel = $ this :: $ permissionModel ; $ this -> permissions = $ permissionModel :: whereHas ( 'roles' , function ( $ query ) { $ query -> whereHas ( 'users' , function ( $ query ) { $ query -> where ( 'id' , $ this -> id ) ; } ) ; } ) -> get ( ) ; } return $ this -> permissions ; }
Get the user permissions.

@return \Illuminate\Database\Eloquent\Collection
Get the user permissions .