@php use App\Enums\PriceType; use App\Enums\PriceTypeTravaux; use App\Enums\MarketingTagType; use App\Enums\Fiscalite; use App\Enums\ProductState; use App\Enums\SurfaceType; use Illuminate\Support\Facades\Auth; // 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; $isDenormandie = $program->fiscalites->contains(function ($fiscalite) { return (($fiscalite->type->value ?? null) === Fiscalite::DENORMANDIE->value); }); // Prix minimum depuis les lots (uniquement les lots non vendus) $prix = []; $types = []; foreach ($program->lots as $lot) { // Filtrer uniquement les lots non vendus (exclure ProductState::VENDU) $isVendu = $lot->states->contains(function($state) { return $state->type->value === ProductState::VENDU->value; }); if ($isVendu) { continue; } $startingPrice = $isDenormandie ? $lot->getTotalLotEtAnnexes() : ($lot->prices->where('type', PriceType::PRIX_IMMO_TTC->value)->first()?->value ?? 0); if ($startingPrice > 0) { $prix[] = $startingPrice; } 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); // 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; } // Commission de l'utilisateur pour ce programme $commission = null; if (Auth::check() && isset($currentApplication)) { $commission = $program->getHighestCommission(Auth::id(), $currentApplication->id); } $appContext = app(\App\Services\AppContext::class); $themeExclu = $appContext->getExcluSrc(); @endphp
@endif
À partir de
{{ number_format($prixMin, 0, ',', ' ') }} € {{ $isHT ? 'HT' : 'TTC' }}
{{ ucwords(strtolower($program->city)) }}
{{ $fiscaliteLibelle }}
À 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
Quote/travaux : {{ $quoteTravaux }} %
@endif @if($commission)Commission : {{ number_format($commissionValue, 2, ',', ' ') }} %@if($isHTCommission) HT@endif
@endif