src/Defender/Traits/Users/HasRoles.php
public function scopeWhichRoles($query, $roles)
    {
        return $query->whereHas('roles', function ($query) use ($roles) {
            $roles = (is_array($roles)) ? $roles : [$roles];

            $query->whereIn('name', $roles);
        });
    }
public function scopeWhichRoles($query, $roles)
    {
        return $query->whereHas('roles', function ($query) use ($roles) {
            $roles = (is_array($roles)) ? $roles : [$roles];

            $query->whereIn('name', $roles);
        });
    }
public function scopeWhichRoles ( $ query , $ roles ) { return $ query -> whereHas ( 'roles' , function ( $ query ) use ( $ roles ) { $ roles = ( is_array ( $ roles ) ) ? $ roles : [ $ roles ] ; $ query -> whereIn ( 'name' , $ roles ) ; } ) ; }
Take user by roles.

@param \Illuminate\Database\Query\Builder $query
@param string|array $roles

@return \Illuminate\Database\Query\Builder
Take user by roles .