collect($trans['sections'])->map(fn ($s) => [ 'title' => $s['title'], 'bgColor' => $s['bg_color'], 'textColor' => $s['text_color'], 'rotation' => $s['rotation'], 'maxWidth' => $s['max_width'] ?? 'max-w-[1000px]', 'edgeOffset' => $s['edge_offset'] ?? '', 'texts' => $s['texts'], 'list' => $s['list'] ?? null, 'textAfterList' => $s['text_after_list'] ?? null, 'image' => $s['image'] ?? null, 'imageCaption' => $s['image_caption'] ?? null, ])->all(), 'communities' => collect($communityTrans['communities']) ->map(fn ($c, $key) => [ 'number' => $c['number'], 'title' => $c['header']['title'], 'rotation' => $c['rotation'], 'href' => route('front.communities.show',$key), ]) ->values() ->all(), ]); } public function show(string $slug): Response { $trans = trans('community_detail_page'); $community = $trans['communities'][$slug] ?? null; if (!$community) { abort(404); } return Inertia::render('front/Pages/Community/DetailCommunity', [ 'metaTitle' => $community['meta']['title'], 'metaDescription' => $community['meta']['description'], 'headerTitle' => $community['header']['title'], 'heading' => $community['heading'], 'roleTitle' => $community['role_title'], 'roleText' => $community['role_text'], 'compositionTitle' => $community['composition_title'], 'compositionItems' => $community['composition_items'], 'closingText' => $community['closing_text'], 'testimonials' => $this->getTestimonials($community), 'otherCommunities' => $this->getOtherCommunities($trans, $slug), 'governanceHref' => route('front.gouvernance.index'), ]); } /** * @param array $community * @return array> */ private function getTestimonials(array $community): array { return collect($community['testimonials'] ?? []) ->map(fn($t) => [ 'quote' => $t['quote'], 'authorName' => $t['author_name'], 'authorRole' => $t['author_role'], 'authorPhoto' => $t['author_photo'], 'logo' => $t['logo'], ])->all(); } /** * @param array $trans * @return array> */ private function getOtherCommunities(array $trans, string $excludeSlug): array { return collect($trans['communities']) ->reject(fn($c, $key) => $key === $excludeSlug) ->map(fn($c, $key) => [ 'number' => $c['number'], 'title' => $c['header']['title'], 'rotation' => $c['rotation'], 'href' => route('front.communities.show', $key), ])->values()->all(); } }