@php use App\Enums\PriceType; use App\Enums\PriceTypeTravaux; use App\Enums\MarketingTagType; use App\Enums\ProductState; use App\Enums\SurfaceType; // Image - utiliser le CDN $images = $program->getMedia('images')->sortBy('order_column'); $firstImage = $images->first(); $image = $firstImage ? getImageFromCDN($firstImage, 'moyenne') : ($themeLogo ?? asset('assets/img/logo.png')); // Fiscalités $fiscalites = $program->fiscalites->pluck('type')->map(fn($f) => $f->label())->toArray(); $fiscaliteLibelle = !empty($fiscalites) ? implode(', ', $fiscalites) : ''; // Date de livraison $dateLivraison = $program->dates->where('type', 'date_livraison')->first(); $dateLivraisonValue = $dateLivraison ? $dateLivraison->value : null; // Prix minimum depuis les lots $prix = []; $types = []; foreach ($program->lots as $lot) { $prixTTC = $lot->prices->where('type', 'prix_ttc')->first()?->value ?? 0; if ($prixTTC > 0) { $prix[] = $prixTTC; } if ($lot->type && $lot->type !== \App\Enums\ProductType::NON_DEFINI) { $types[] = $lot->type->label(); } } $prixMin = !empty($prix) ? min($prix) : 0; $types = array_unique($types); asort($types); // Exclusivité $hasExclusivite = $program->marketingTags()->where('type', MarketingTagType::EXCLUSIVITE->value)->exists(); // Opérations commerciales (opeComs) $operations_commerciales = []; foreach ($program->opeComs as $opeCom) { if ($opeCom->text) { $operations_commerciales[$opeCom->type->label()] = $opeCom->text; } } // Quote/travaux - calculer le pourcentage moyen $quoteTravaux = null; $lotsWithTravaux = $program->lots() ->whereHas('prices', function($q) { $q->whereIn('type', [ PriceTypeTravaux::PRIX_TRAVAUX_ELIGIBLE->value, PriceTypeTravaux::PRIX_TRAVAUX_NON_ELIGIBLE->value ]) ->where('value', '>', 0); }) ->with(['prices' => function($q) { $q->whereIn('type', [ 'prix_ttc', PriceTypeTravaux::PRIX_TRAVAUX_ELIGIBLE->value, PriceTypeTravaux::PRIX_TRAVAUX_NON_ELIGIBLE->value ]); }]) ->get(); if ($lotsWithTravaux->count() > 0) { $quotes = []; foreach ($lotsWithTravaux as $lot) { $prixTTC = $lot->prices->where('type', 'prix_ttc')->first()?->value ?? 0; $prixTravaux = $lot->prices ->whereIn('type', [ PriceTypeTravaux::PRIX_TRAVAUX_ELIGIBLE->value, PriceTypeTravaux::PRIX_TRAVAUX_NON_ELIGIBLE->value ]) ->sum('value'); if ($prixTTC > 0 && $prixTravaux > 0) { $quotes[] = ($prixTravaux / $prixTTC) * 100; } } if (!empty($quotes)) { $quoteTravaux = round(max($quotes)); } } // Déterminer si TTC ou HT (basé sur la fiscalité principale) $isHT = false; $mainFiscalite = $program->fiscalites->first(); if ($mainFiscalite && $mainFiscalite->type->value === 'monument_historique') { $isHT = true; } $appContext = app(\App\Services\AppContext::class); $themeExclu = $appContext->getExcluSrc(); @endphp
{{-- Images carousel (mobile) --}}
{{-- Responsive --}}
@if($dateLivraisonValue) Livré en {{ date('Y', strtotime($dateLivraisonValue)) }} @endif @if($hasExclusivite) Exclusivité Exclusivité @endif
{{-- Informations du programme (mobile + desktop) --}}

{{ ucwords(strtolower($program->name)) }}

{{-- Responsive --}}

À partir de
{{ number_format($prixMin, 0, ',', ' ') }} € {{ $isHT ? 'HT' : 'TTC' }}

{{-- Responsive --}}
{{-- Desktop --}}
@if($hasExclusivite) Exclusivité Exclusivité @endif @if($dateLivraisonValue) Livré en {{ date('Y', strtotime($dateLivraisonValue)) }} @endif
{{-- Desktop + Responsive --}}

{{ ucwords(strtolower($program->city)) }}

{{ $fiscaliteLibelle }}

{{-- Desktop --}}

À partir de
{{ number_format($prixMin, 0, ',', ' ') }} € {{ $isHT ? 'HT' : 'TTC' }} @if(!empty($types)) Du {{ $types[array_key_first($types)] }} au {{ $types[array_key_last($types)] }} @endif

{{-- Desktop --}}
    @if($quoteTravaux)
  • Quote/travaux : {{ $quoteTravaux }} %
  • @endif
{{-- Responsive --}}
@if($quoteTravaux)

Quote/travaux : {{ $quoteTravaux }} %

@endif
{{-- Desktop --}} @if(!empty($operations_commerciales))
    @foreach($operations_commerciales as $operation_commerciale => $value)
  • {{ $operation_commerciale }}
  • @endforeach
@endif
{{-- Images carousel (desktop) --}}