app/Models/Role.php
/**
     * Filter roles to show filter depending of the permissions
     *
     * @param Builder $query
     * @param \User $user
     * @return Builder
     */
Filter roles to show filter depending of the permissions
@param Builder $query
@param \User $user
@return Builder
Filter roles to show filter depending of the permissions @param Builder $query @param \ User $user @return Builder
public function scopeFilterByUserPermissions($query, User $user)
    {
        if ($user->hasRole('admin')) {
            return $query;
        }
        return $query->whereNotIn('name', ['admin']);
    }
public function scopeFilterByUserPermissions ( $ query , User $ user ) { if ( $ user -> hasRole ( 'admin' ) ) { return $ query ; } return $ query -> whereNotIn ( 'name' , [ 'admin' ] ) ; }
Filter roles to show filter depending of the permissions
 @param Builder $query
 @param \User $user
 @return Builder
Filter roles to show filter depending of the permissions @param Builder $query @param \ User $user @return Builder