public function scopeWhereRole($query, $role)
    {
        return $query->whereHas('roles', function ($query) use ($role) {
            return $query->where('keyword', $role);
        });
    }
public function scopeWhereRole($query, $role)
    {
        return $query->whereHas('roles', function ($query) use ($role) {
            return $query->where('keyword', $role);
        });
    }
public function scopeWhereRole ( $ query , $ role ) { return $ query -> whereHas ( 'roles' , function ( $ query ) use ( $ role ) { return $ query -> where ( 'keyword' , $ role ) ; } ) ; }
Query Scope
Get all the users that has the role
@param $query
@param $role
@return mixed
Query Scope Get all the users that has the role