@props(['key' => null])
{{-- Collapsible "How it works" helper. Content lives in config/how-it-works.php,
looked up by the current route name (most-specific segment wins), or by an
explicit key: . Renders nothing when no
content matches, so it is safe to include on every page. --}}
@php
$hiwRoute = \Illuminate\Support\Facades\Route::currentRouteName() ?? '';
$hiwCandidates = $key ? [$key] : [];
$hiwParts = array_values(array_filter(explode('.', $hiwRoute)));
for ($i = count($hiwParts); $i >= 1; $i--) {
$hiwCandidates[] = implode('.', array_slice($hiwParts, 0, $i));
}
// Flat lookup: keys like "tour.category" contain dots, so config() dot
// notation would mis-read them as nesting.
$hiwAll = config('how-it-works', []);
$hiw = null;
foreach ($hiwCandidates as $hiwCandidate) {
if ($hiwCandidate && isset($hiwAll[$hiwCandidate])) {
$hiw = $hiwAll[$hiwCandidate];
break;
}
}
$hiwId = 'hiw-' . substr(md5(($key ?? '') . '|' . $hiwRoute), 0, 10);
@endphp
@if($hiw)