Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions app/Actions/ViewDataAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,27 @@
$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) {

Check failure on line 62 in app/Actions/ViewDataAction.php

View workflow job for this annotation

GitHub Actions / pull-request | ci larastan

Out of 146 possible param types, only 144 - 98.6 % actually have it. Add more param types to get over 99 %
$sections = $contact->sections ?? [];

return array_key_exists($section, $sections);
})
->map(fn ($contact) => ContactDTO::fromModel($contact, $section, $locale));

Check failure on line 67 in app/Actions/ViewDataAction.php

View workflow job for this annotation

GitHub Actions / pull-request | ci larastan

Out of 146 possible param types, only 144 - 98.6 % actually have it. Add more param types to get over 99 %

return [$section => $contacts];
return [$section => $contacts->values()];
})->all();
});
}
Comment on lines +62 to 72
Copy link

Copilot AI Jun 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider extracting the anonymous filter function into a separate, well-named method to improve clarity and potential reusability.

Copilot uses AI. Check for mistakes.
Expand Down
2 changes: 1 addition & 1 deletion database/seeders/Paperflakes/ContactsTableSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]
);

Expand Down
Loading