33 lines
1.7 KiB
PHP
33 lines
1.7 KiB
PHP
@if ((bool) ($data['enabled'] ?? true))
|
|
@php
|
|
$includeIds = collect(explode(',', (string) ($data['include_ids'] ?? '')))->map(static fn ($id) => (int) trim($id))->filter();
|
|
$excludeIds = collect(explode(',', (string) ($data['exclude_ids'] ?? '')))->map(static fn ($id) => (int) trim($id))->filter();
|
|
$items = collect($faqs ?? [])
|
|
->when($includeIds->isNotEmpty(), static fn ($collection) => $collection->filter(static fn ($item) => $includeIds->contains((int) $item->id)))
|
|
->reject(static fn ($item) => $excludeIds->contains((int) $item->id))
|
|
->take(max(1, (int) ($data['limit'] ?? 12)));
|
|
@endphp
|
|
|
|
@if ($items->isNotEmpty())
|
|
<section class="section">
|
|
<div class="wrap faq">
|
|
<div>
|
|
@if (filled($data['eyebrow'] ?? null))<span class="section-label">{{ $data['eyebrow'] }}</span>@endif
|
|
@if (filled($data['heading'] ?? null))<h2>{{ $data['heading'] }}</h2>@endif
|
|
@if (filled($data['description'] ?? null))<p>{{ $data['description'] }}</p>@endif
|
|
</div>
|
|
<div>
|
|
@foreach ($items as $faq)
|
|
<article>
|
|
<button type="button" @click="openFaq = openFaq === {{ (int) $faq->id }} ? null : {{ (int) $faq->id }}">
|
|
{{ $faq->question }}<span>+</span>
|
|
</button>
|
|
<p x-cloak x-show="openFaq === {{ (int) $faq->id }}">{{ $faq->answer }}</p>
|
|
</article>
|
|
@endforeach
|
|
</div>
|
|
</div>
|
|
</section>
|
|
@endif
|
|
@endif
|