*/ public function handle(string $search): Collection { return Member::search($search)->query(fn ($query) => $query->ordered())->get(); } public function asController(ActionRequest $request): AnonymousResourceCollection { if (null !== $request->input('minLength') && 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(); } }