public function getPermissionsViaRoles(): Collection
    {
        return $this->load('roles', 'roles.permissions')
            ->roles->flatMap(function ($role) {
                return $role->permissions;
            })->sort()->values();
    }
public function getPermissionsViaRoles(): Collection
    {
        return $this->load('roles', 'roles.permissions')
            ->roles->flatMap(function ($role) {
                return $role->permissions;
            })->sort()->values();
    }
public function getPermissionsViaRoles ( ) : Collection { return $ this -> load ( 'roles' , 'roles.permissions' ) -> roles -> flatMap ( function ( $ role ) { return $ role -> permissions ; } ) -> sort ( ) -> values ( ) ; }
Return all the permissions the model has via roles.
Return all the permissions the model has via roles .