options(fn (): array => self::photoOptions()) ->allowHtml() ->searchable() ->native(false); } /** * @return array> */ public static function photoOptions(): array { return Photo::query()->with('media')->orderBy('category')->orderBy('sort_order')->get() ->groupBy(fn (Photo $photo): string => $photo->category->getLabel()) ->map(fn ($photos): array => $photos->mapWithKeys(fn (Photo $photo): array => [$photo->id => self::optionLabel($photo)])->all()) ->all(); } public static function optionLabel(Photo $photo): string { $thumbnail = $photo->url('sm'); $image = $thumbnail !== '' ? '' : ''; $hidden = $photo->is_published ? '' : ' (ausgeblendet)'; $seasons = $photo->appearanceNames() === [] ? '' : ' ยท nur '.e(implode(', ', $photo->appearanceNames())).''; return ''.$image.''.e($photo->alt_text).$seasons.$hidden.''; } }