diff --git a/app/Actions/ViewDataAction.php b/app/Actions/ViewDataAction.php index 632d643..09f944f 100644 --- a/app/Actions/ViewDataAction.php +++ b/app/Actions/ViewDataAction.php @@ -46,21 +46,27 @@ public function contacts(string $locale): object $key = Str::slug("contacts_published_{$locale}"); return Cache::rememberForever($key, function () use ($locale) { + $publishedContacts = Contact::query() + ->where('published', true) + ->orderBy('name') + ->get(); + return (object) collect([ ContactSectionEnum::EMPLOYEE_SERVICES, ContactSectionEnum::EMPLOYEE_PRODUCTS, ContactSectionEnum::EMPLOYEE_ADMINISTRATION, ContactSectionEnum::COLLABORATIONS, ContactSectionEnum::BOARD_MEMBERS, - ])->mapWithKeys(function (string $section) use ($locale) { - $contacts = Contact::query() - ->where('published', true) - ->whereRaw("JSON_CONTAINS_PATH(sections, 'one', '$.\"$section\"')") - ->orderBy('name') - ->get() + ])->mapWithKeys(function (string $section) use ($publishedContacts, $locale) { + $contacts = $publishedContacts + ->filter(function ($contact) use ($section) { + $sections = $contact->sections ?? []; + + return array_key_exists($section, $sections); + }) ->map(fn ($contact) => ContactDTO::fromModel($contact, $section, $locale)); - return [$section => $contacts]; + return [$section => $contacts->values()]; })->all(); }); } diff --git a/database/seeders/Paperflakes/ContactsTableSeeder.php b/database/seeders/Paperflakes/ContactsTableSeeder.php index f54cc82..0a9cad3 100644 --- a/database/seeders/Paperflakes/ContactsTableSeeder.php +++ b/database/seeders/Paperflakes/ContactsTableSeeder.php @@ -143,7 +143,7 @@ public function run(): void ], ], 'icons' => [], - 'image' => 'https://res.cloudinary.com/codebar/image/upload/c_thumb,g_face,w_400,h_400,f_auto,q_auto/www-paperflakes-ch/people/drg.webp', + 'image' => 'https://res.cloudinary.com/codebar/image/upload/w_400,h_400,f_auto,q_auto/www-paperflakes-ch/people/drg_e_background_removal_f_png.webp', ] );