*/ public function handle(string $search): Collection { return Member::search($search)->query(fn ($query) => $query->ordered())->get(); } public function asController(ActionRequest $request): AnonymousResourceCollection { if ($request->input('minLength') !== null && strlen($request->input('search')) < $request->input('minLength')) { return MemberResource::collection($this->empty()); } return MemberResource::collection($this->handle($request->input('search', ''))); } /** * @return Collection */ private function empty(): Collection { return Member::where('id', -1)->get(); } }