Skip to content

Commit bb3ebc9

Browse files
authored
Merge pull request #18 from codebar-ag/feature-feature
Feature Feature
2 parents 4c209fe + a4f12ce commit bb3ebc9

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

app/Actions/ViewDataAction.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,27 @@ public function contacts(string $locale): object
4646
$key = Str::slug("contacts_published_{$locale}");
4747

4848
return Cache::rememberForever($key, function () use ($locale) {
49+
$publishedContacts = Contact::query()
50+
->where('published', true)
51+
->orderBy('name')
52+
->get();
53+
4954
return (object) collect([
5055
ContactSectionEnum::EMPLOYEE_SERVICES,
5156
ContactSectionEnum::EMPLOYEE_PRODUCTS,
5257
ContactSectionEnum::EMPLOYEE_ADMINISTRATION,
5358
ContactSectionEnum::COLLABORATIONS,
5459
ContactSectionEnum::BOARD_MEMBERS,
55-
])->mapWithKeys(function (string $section) use ($locale) {
56-
$contacts = Contact::query()
57-
->where('published', true)
58-
->whereRaw("JSON_CONTAINS_PATH(sections, 'one', '$.\"$section\"')")
59-
->orderBy('name')
60-
->get()
60+
])->mapWithKeys(function (string $section) use ($publishedContacts, $locale) {
61+
$contacts = $publishedContacts
62+
->filter(function ($contact) use ($section) {
63+
$sections = $contact->sections ?? [];
64+
65+
return array_key_exists($section, $sections);
66+
})
6167
->map(fn ($contact) => ContactDTO::fromModel($contact, $section, $locale));
6268

63-
return [$section => $contacts];
69+
return [$section => $contacts->values()];
6470
})->all();
6571
});
6672
}

database/seeders/Paperflakes/ContactsTableSeeder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public function run(): void
143143
],
144144
],
145145
'icons' => [],
146-
'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',
146+
'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',
147147
]
148148
);
149149

0 commit comments

Comments
 (0)