@php use App\Addons\Faq\Models\Faq; use App\Models\Store\Group; use App\Models\Store\Product; $currentUrl = request()->path(); $segments = explode('/', trim($currentUrl, '/')); $detectedGroup = null; $detectedProduct = null; if (count($segments) >= 2 && $segments[0] === 'store') { if (isset($segments[1]) && $segments[1] === 'basket' && isset($segments[2]) && $segments[2] === 'config') { $productId = $segments[3] ?? null; if ($productId && is_numeric($productId)) { $detectedProduct = Product::find((int) $productId); } } else { $groupSlug = $segments[1] ?? null; if ($groupSlug) { $detectedGroup = Group::where('slug', $groupSlug)->first(); } // Check for subgroup $subgroupSlug = $segments[2] ?? null; if ($subgroupSlug && $detectedGroup) { $subgroup = Group::where('slug', $subgroupSlug) ->where('parent_id', $detectedGroup->id) ->first(); if ($subgroup) { $detectedGroup = $subgroup; } } } } $group = $detectedGroup ?? $subgroup ?? $group ?? null; $product = $detectedProduct ?? $product ?? null; if ($group) { $faqs = $faqs ?? Faq::forContext($group); } else { $faqs = $faqs ?? Faq::forContext(null, $product); } $headingTitle = $title ?? __('faq::messages.client.title'); $headingDescription = $description ?? __('faq::messages.client.description'); $isGroupContext = false; $usefulnessEnabled = setting('faq_usefulness_enabled', true); $hideHeader = $hideHeader ?? false; @endphp @if($faqs->isNotEmpty())
@unless($hideHeader)

{{ $headingTitle }}

{{ $headingDescription }}

@endunless
@if($isGroupContext)
@foreach ($faqs as $faq)

{{ $faq->trans('title') }}

{!! nl2br($faq->trans('answer')) !!}

@if($usefulnessEnabled)
@if(($faq->total_votes ?? 0) > 0) {{ __('faq::messages.client.useful_stats_template', ['yes' => $faq->useful_yes_count ?? 0, 'total' => $faq->total_votes, 'percent' => $faq->useful_ratio ?? 0]) }} @else {{ __('faq::messages.client.useful_prompt') }} @endif

{{ session('faq_usefulness_'.$faq->id) }}

@endif
@endforeach
@else
@foreach ($faqs as $faq)

{{ $faq->trans('title') }}

{!! nl2br($faq->trans('answer')) !!}

@if($usefulnessEnabled)
@if(($faq->total_votes ?? 0) > 0) {{ __('faq::messages.client.useful_stats_template', ['yes' => $faq->useful_yes_count ?? 0, 'total' => $faq->total_votes, 'percent' => $faq->useful_ratio ?? 0]) }} @else {{ __('faq::messages.client.useful_prompt') }} @endif

{{ session('faq_usefulness_'.$faq->id) }}

@endif
@endforeach
@endif
@endif @once @if($usefulnessEnabled) @endif @endonce