> $sections */ $sections = $trans['sections']; /** @var array> $communities */ $communities = $communityTrans['communities']; return Inertia::render('front/Pages/Community/Gouvernance', [ 'sections' => collect($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($communities) ->only(['amont', 'transformateurs', 'aval', 'autres', 'scientifique']) ->map(fn ($c, $key) => [ 'number' => $c['number'] ?? '', 'title' => $c['header']['title'] ?? '', 'rotation' => $c['rotation'] ?? 0, 'href' => route('front.communities.show', $key), ]) ->values() ->all(), ]); } public function show(string $slug): Response { $trans = trans('community_detail_page'); $community = $trans['communities'][$slug] ?? null; abort_unless($community, 404); $entry = $trans['communities'][$slug] ?? null; $realSlug = $entry['redirect_slug'] ?? $slug; $community = $trans['communities'][$realSlug]; 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'], 'compositionContent' => $community['composition_content'], 'testimonials' => $this->getTestimonials($community), 'otherCommunities' => $this->getOtherCommunities($trans, $slug), 'governanceHref' => route('front.gouvernance.index'), 'sections' => $community['sections'] ?? [], 'image' => $community['image'] ?? null, 'imageCaption' => $community['image_caption'] ?? null, ]); } /** * @param array $community * @return array> */ private function getTestimonials(array $community): array { /** @var array> $testimonials */ $testimonials = $community['testimonials'] ?? []; return collect($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 { // Si on affiche transformateurs ou aval, on exclut les deux (contenu fusionné) $slugsToExclude = in_array($excludeSlug, ['transformateurs', 'aval'], true) ? ['transformateurs', 'aval'] : [$excludeSlug]; /** @var array> $communities */ $communities = $trans['communities']; return collect($communities) ->only(['amont', 'transformateurs', 'aval', 'autres', 'scientifique']) ->reject(fn ($c, $key) => in_array($key, $slugsToExclude, true)) ->map(fn ($c, $key) => [ 'number' => $c['number'], 'title' => $c['header']['title'], 'rotation' => $c['rotation'], 'href' => route('front.communities.show', $key), ]) ->values() ->all(); } }