getBuilder()->withCount('servers', 'subuserOf') ->search($this->getSearchTerm()) ->paginate(50, $this->getColumns()); } /** * Return all matching models for a user in a format that can be used for dropdowns. * * @param string $query * @return \Illuminate\Support\Collection */ public function filterUsersByQuery(string $query): Collection { $this->setColumns([ 'id', 'email', 'username', 'name_first', 'name_last', ]); $instance = $this->getBuilder()->setSearchTerm($query)->get($this->getColumns()); return $instance->transform(function ($item) { $item->md5 = md5(strtolower($item->email)); return $item; }); } }