@props([ 'service', 'slug', 'heroCards' => [], 'contactSlug' => null, 'locationSuffix' => '', 'localizedRoute', ]) @php use App\Helpers\ServiceHeroCards; use Illuminate\Support\Str; $splitCard = static function (string $title, string $body = ''): array { $title = trim($title); $body = trim($body); if ($body !== '' && mb_strtolower($body) !== mb_strtolower($title)) { return [$title, $body]; } $period = strpos($title, '.'); if ($period !== false && $period > 0 && $period <= 72) { $headline = trim(substr($title, 0, $period)); $rest = trim(substr($title, $period + 1)); return [$headline, $rest !== '' ? $rest : $title]; } return [$title, '']; }; $valueCards = array_values(array_filter( $service['benefitCards'] ?? [], static fn ($card): bool => is_array($card) && trim((string) ($card['title'] ?? ($card['text'] ?? ''))) !== '' )); if ($valueCards === []) { $outcomeTitles = array_values(array_filter( ! empty($service['outcomes']) ? $service['outcomes'] : ($service['features'] ?? []), static fn ($item): bool => trim((string) $item) !== '' )); $benefitBodies = array_values($service['benefits'] ?? []); foreach (array_slice($outcomeTitles !== [] ? $outcomeTitles : array_filter($service['benefits'] ?? []), 0, 4) as $index => $line) { [$headline, $body] = $splitCard((string) $line, (string) ($benefitBodies[$index] ?? '')); $valueCards[] = [ 'title' => $headline, 'text' => $body !== '' ? $body : $headline, ]; } } $valueCards = array_slice($valueCards, 0, 4); $pageHeroCards = array_values($heroCards); if ($pageHeroCards === []) { $pageHeroCards = ServiceHeroCards::forSlug($slug, $service, 4); } $heroExclude = array_map( static fn (array $card): string => (string) ($card['image'] ?? ''), $pageHeroCards ); if (! empty($service['listingImage'])) { $heroExclude[] = (string) $service['listingImage']; } $spotBackgrounds = ServiceHeroCards::spotBackgrounds($slug, $service, $heroExclude, 2); $spotBgPrimary = $spotBackgrounds[0] ?? null; $spotBgSecondary = $spotBackgrounds[1] ?? null; $introFull = trim((string) ($service['intro'] ?? ($service['heroDescription'] ?? ''))); if ($introFull === '') { $introFull = __('messages.service_detail.value_desc', ['service' => strtolower($service['name'])]); } $introSentences = preg_split('/(?<=[.!?])\s+/u', $introFull, -1, PREG_SPLIT_NO_EMPTY) ?: [$introFull]; $introHeadline = trim($introSentences[0] ?? $introFull); $introSubhead = trim(implode(' ', array_slice($introSentences, 1))); $heroStory = $valueCards[0] ?? null; $featureStory = $valueCards[1] ?? null; @endphp @if(count($valueCards) > 0)
@if($heroStory)
$spotBgPrimary === null, ])> @if($spotBgPrimary) @endif

{{ __('messages.service_detail.value_spot_plan_label') }}

{{ $heroStory['title'] }}

@if(! empty($heroStory['text']))

{{ $heroStory['text'] }}

@endif
@endif @if($featureStory)
$spotBgSecondary === null, ])> @if($spotBgSecondary) @endif

{{ __('messages.service_detail.value_spot_experience_label') }}

{{ $featureStory['title'] }}

{{ $featureStory['text'] }}

@endif

{{ __('messages.service_detail.value_tiles_label') }}

{{ __('messages.service_detail.value_tiles_desc') }}

@foreach($valueCards as $i => $card)

{{ $card['title'] }}

{{ $card['text'] }}

@endforeach

{{ $service['ctaText'] ?? __('messages.service_detail.start_your_project', ['location_suffix' => '']) }}

@endif