> */ public function __invoke(User $user, string $search, int $limit): array { $query = Download::query()->whereIn('folder_id', $this->tree->visibleIds($user) ?: [0])->whereNotNull('current_version_id')->with('currentVersion'); GlobalSearch::whereTerms($query, ['title', 'description'], $search); return $query->orderBy('title')->limit($limit)->get()->map(fn (Download $download) => [ 'title' => $download->title, 'url' => $download->downloadUrl(), 'external' => true, 'excerpt' => GlobalSearch::excerpt($download->description, $search), 'meta' => collect([$this->tree->get($download->folder_id)['name'] ?? null, strtoupper($download->currentVersion?->extension() ?? '')])->filter()->implode(' · '), 'file' => $download->currentVersion?->extension(), ])->all(); } }