public function scopeHasRolesId(Builder $query, array $rolesId = []): Builder
    {
        $query->with('roles')->whereNotNull('users.id');

        if (! empty($rolesId)) {
            $query->whereHas('roles', function ($query) use ($rolesId) {
                $query->whereIn(Role::column('id'), $rolesId);
            });
        }

        return $query;
    }
public function scopeHasRolesId(Builder $query, array $rolesId = []): Builder
    {
        $query->with('roles')->whereNotNull('users.id');

        if (! empty($rolesId)) {
            $query->whereHas('roles', function ($query) use ($rolesId) {
                $query->whereIn(Role::column('id'), $rolesId);
            });
        }

        return $query;
    }
public function scopeHasRolesId ( Builder $ query , array $ rolesId = [ ] ) : Builder { $ query -> with ( 'roles' ) -> whereNotNull ( 'users.id' ) ; if ( ! empty ( $ rolesId ) ) { $ query -> whereHas ( 'roles' , function ( $ query ) use ( $ rolesId ) { $ query -> whereIn ( Role :: column ( 'id' ) , $ rolesId ) ; } ) ; } return $ query ; }
Search user based on keyword as roles id.

@param  \Illuminate\Database\Eloquent\Builder  $query
@param  array  $rolesId

@return \Illuminate\Database\Eloquent\Builder
Search user based on keyword as roles id .