$terms * @return list> */ public function __invoke(User $user, array $terms, int $limit): array { $query = User::query()->active(); Knowledge::whereAny($query, ['first_name', 'last_name', 'job_title', 'department', 'location', 'about'], $terms); return $query->orderBy('last_name')->limit($limit)->get()->map(function (User $person) use ($user) { $extra = collect($this->fields->visibleValues($person, $user))->map(fn (array $f) => $f['label'].': '.$f['value'])->implode('. '); return [ 'title' => $person->name.($person->job_title ? ' – '.$person->job_title : ''), 'url' => route('people.show', $person), 'text' => implode(' ', array_filter([ $person->name.' arbeitet'.($person->job_title ? ' als '.$person->job_title : '').($person->department ? ' im Bereich '.$person->department : '').($person->location ? ', Standort '.$person->location : '').'.', $person->phone ? 'Telefon: '.$person->phone.'.' : null, $person->mobile ? 'Mobil: '.$person->mobile.'.' : null, 'E-Mail: '.$person->email.'.', $extra ? $extra.'.' : null, ]))."\n".(string) $person->about, 'meta' => collect([$person->department, $person->location])->filter()->implode(', ') ?: null, ]; })->all(); } }