@php use Botble\Base\Facades\BaseHelper; use Botble\Media\Facades\RvMedia; use Botble\Shortcode\Facades\Shortcode; // Tabs items: each tab is one Q&A. // - `category`: groups questions under a category heading. Items with the // same `category` are rendered together; switching to a new // value starts a new group. // - `category_id`: used as the in-page anchor + sidebar nav target. // - `question`, `answer`: the FAQ pair itself. $items = Shortcode::fields()->getTabsData( ['category', 'category_id', 'question', 'answer'], $shortcode ); // Group consecutive items by category_id (preserves seeder/admin order). $groups = []; foreach ($items as $item) { $cid = (string) ($item['category_id'] ?? ''); if (! $cid) { continue; } if (! isset($groups[$cid])) { $groups[$cid] = [ 'id' => $cid, 'title' => (string) ($item['category'] ?? $cid), 'items' => [], ]; } $groups[$cid]['items'][] = [ 'q' => (string) ($item['question'] ?? ''), 'a' => (string) ($item['answer'] ?? ''), ]; } $groups = array_values($groups); // Sidebar promo banner. $sidebarImage = (string) ($shortcode->sidebar_image ?? ''); $sidebarTitle = (string) ($shortcode->sidebar_title ?? ''); $sidebarSubtitle = (string) ($shortcode->sidebar_subtitle ?? ''); $sidebarCta = (string) ($shortcode->sidebar_cta ?? ''); $sidebarUrl = (string) ($shortcode->sidebar_url ?? ''); $categoriesLabel = (string) ($shortcode->categories_label ?? __('Categories')); $sidebarSrc = $sidebarImage ? RvMedia::getImageUrl($sidebarImage, null, false, RvMedia::getDefaultImage()) : null; @endphp {{-- .section-faq accordion cursor + arrow rotate rules live in assets/sass/component/_inline-migrated.scss. --}}
htmlAttributes() !!} class="section-faq flat-spacing">
    @foreach ($groups as $group)
  • @if ($group['title'])

    {{ $group['title'] }}

    @endif
    @foreach ($group['items'] as $i => $entry) @php($targetId = $group['id'] . '-' . ($i + 1))

    {!! BaseHelper::clean($entry['a']) !!}

    @endforeach
  • @endforeach