Files
laravel-manager-packagist/resources/views/blocks/cards.blade.php
T
2026-12-04 16:52:00 +00:00

24 lines
1.5 KiB
PHP

@php
// What a record shows is found under the usual names: title or name, summary / story / quote / role, photo, url.
$pick = fn (array $item, array $keys) => collect($keys)->map(fn ($key) => $item[$key] ?? null)->first(fn ($value) => is_string($value) && $value !== '');
@endphp
<section class="mb-block mb-cards {{ $classes }}">
<div class="mb-inner">
@if (($data['eyebrow'] ?? '') !== '')<p class="mb-eyebrow">{{ $data['eyebrow'] }}</p>@endif
@if (($data['title'] ?? '') !== '')<h2>{{ $data['title'] }}</h2>@endif
<div class="mb-grid">
@foreach ($items as $item)
@php($url = $pick($item, ['url', 'link']))
<article class="mb-card">
@if ($photo = $pick($item, ['photo', 'picture', 'image']))<img src="{{ \IriksIT\Manager\Support\Blocks::safeUrl($photo) }}" alt="" loading="lazy">@endif
<h3>@if ($url)<a href="{{ \IriksIT\Manager\Support\Blocks::safeUrl($url) }}">{{ $pick($item, ['title', 'name', 'label']) }}</a>@else{{ $pick($item, ['title', 'name', 'label']) }}@endif</h3>
@if ($text = $pick($item, ['summary', 'story', 'quote', 'intro', 'role']))<p>{{ $text }}</p>@endif
</article>
@endforeach
</div>
@if (($data['button_label'] ?? '') !== '')
@include('manager::blocks.partials.buttons', ['buttons' => [['label' => $data['button_label'], 'url' => $data['button_url'] ?? '', 'style' => 'secondary']]])
@endif
</div>
</section>