@php use App\Enums\PriceType; use App\Enums\PriceTypeTravaux; use App\Enums\MarketingTagType; // Image - utiliser le CDN $firstMedia = $program->getFirstMedia('images'); $image = $firstMedia ? getImageFromCDN($firstMedia, 'miniature') : ($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 $minPrice = $program->lots() ->whereHas('prices', function($q) { $q->where('type', 'prix_ttc') ->where('value', '>', 0); }) ->with(['prices' => function($q) { $q->where('type', 'prix_ttc') ->where('value', '>', 0) ->orderBy('value', 'asc'); }]) ->first(); $prixMin = $minPrice && $minPrice->prices->first() ? $minPrice->prices->first()->value : 0; // Exclusivité $hasExclusivite = $program->marketingTags()->where('type', MarketingTagType::EXCLUSIVITE->value)->exists(); // Opérations commerciales (opeComs) $hasOpeComs = $program->opeComs()->exists() || $program->lots()->whereHas('opeComs')->exists(); // TVA 5.5% - vérifier si au moins un lot a un prix_tva_5_5 $hasTva5 = $program->lots() ->whereHas('prices', function($q) { $q->where('type', PriceType::PRIX_TVA_5_5->value) ->where('value', '>', 0); }) ->exists(); // LLI (TVA 10%) - vérifier si au moins un lot a un prix_tva_10 $hasLli = $program->lots() ->whereHas('prices', function($q) { $q->where('type', PriceType::PRIX_TVA_10->value) ->where('value', '>', 0); }) ->exists(); // 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; } @endphp
{{ strtolower($program->name) }}
@if($dateLivraisonValue) Livré en {{ date('Y', strtotime($dateLivraisonValue)) }} @endif @if($hasOpeComs) @endif @if($hasExclusivite) Exclusivité Exclusivité @endif

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

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