@extends('model') @section('content') {{-- --}}
@csrf @php // Normalisation des données & variables $data = is_array($data ?? null) ? $data : []; $custumsFields = $custumsFields ?? []; $pkgId = data_get(Auth::user(), 'abonnement_actuel.package_id'); // Catégorie principale $categoryId = data_get($data, 'category_id'); $category = $categoryId ? \App\Models\Category::find($categoryId) : null; $categoryName = $category ? (json_decode($category->name, true)[app()->getLocale()] ?? $category->name) : 'Non renseignée'; $mainCatId = $category ? ($category->parent_id ?? $category->id) : null; // Ville $cityId = data_get($data, 'city_id'); $city = $cityId ? \App\Models\City::find($cityId) : null; $cityName = $city ? (json_decode($city->name, true)[app()->getLocale()] ?? (json_decode($city->name, true)['en'] ?? $city->name)) : 'Non renseignée'; // Prix $price = (int) data_get($data, 'price', 0); /** * Fonction pour formater la valeur d'un champ personnalisé avec son unité * * @param $field * @param $value */ function formatCustomFieldValue($field, $value) { $fieldName = strtolower(data_get($field, 'name', '')); $fieldId = data_get($field, 'id'); $fieldType = data_get($field, 'type'); // Pour les champs de type select ou radio, on doit chercher la valeur correspondante dans les options if (in_array($fieldType, ['select', 'radio'], true)) { // Chercher l'option qui correspond à l'ID stocké $options = data_get($field, 'options', []); $selectedOption = collect($options)->firstWhere('id', $value); $value = $selectedOption ? data_get($selectedOption, 'value', $value) : $value; } // Pour les checkbox multiples if ($fieldType === 'checkbox_multiple') { $raw = $value; $selectedValues = is_array($raw) ? $raw : json_decode($raw ?? '[]', true); $value = implode(', ', $selectedValues ?? []); } // Appliquer les unités après avoir obtenu la bonne valeur // Pour la catégorie Immobilier (ID 37) - champ Taille if ($fieldId == 9 || $fieldName == 'taille') { if (!empty($value) && is_numeric($value)) { return $value . ' m²'; } return $value; } // Pour le nombre de pièces if ($fieldId == 10 || $fieldName == 'pièces') { if (!empty($value)) { // Vérifier si la valeur est déjà un nombre ou si c'est un texte comme "> 10" if (is_numeric($value) || $value == '> 10') { return $value . ' pièce(s)'; } return $value; } return $value; } return $value; } @endphp

Résumé et médias

Média(s)

@if(!empty(data_get($data, 'temp_images'))) @foreach(data_get($data, 'temp_images', []) as $index => $image)
Image {{ $index + 1 }}
@endforeach @else

Aucune image sélectionnée

@endif @if($pkgId == 7) @if(!empty(data_get($data, 'temp_videos'))) @foreach(data_get($data, 'temp_videos', []) as $index => $video)
{{ data_get($video, 'name', '') }}
@endforeach @endif @endif

Résumé de votre annonce

Informations principales
  • Titre: {{ data_get($data, 'title', '—') }}
  • Catégorie: {{ $categoryName }}
  • Prix: {{ $price ? number_format($price, 0, ',', ' ') . ' FCFA' : '—' }}
  • @if (!in_array($mainCatId, [37, 73, 97, 114, 122, 140, 166], true))
  • Livraison gratuite: {{ data_get($data, 'freeDelivery') ? 'Oui' : 'Non' }}
  • @endif @if (!is_null($mainCatId) && $mainCatId !== 166)
  • Négociable: {{ data_get($data, 'negotiable') ? 'Oui' : 'Non' }}
  • @endif
@if (count($custumsFields) > 0)
Informations supplémentaires
    @foreach ($custumsFields as $field) @php $cfId = data_get($field, 'id'); $cfKey = $cfId ? 'cf_' . $cfId : null; $type = data_get($field, 'type'); $exists = $cfKey ? !is_null(data_get($data, $cfKey)) : false; $rawValue = $exists ? data_get($data, $cfKey) : null; @endphp @if ($exists)
  • {{ data_get($field, 'name', '') }}:  @php // Appliquer le formatage avec unités $formattedValue = formatCustomFieldValue($field, $rawValue); @endphp {!! $formattedValue !!}
  • @endif @endforeach
@endif
Contact
  • Nom: {{ data_get($data, 'contact_name', '—') }}
  • Email: {{ data_get($data, 'email', '—') }}
  • Téléphone: {{ data_get($data, 'phone', '—') }}
  • Ville: {{ $cityName }}
Description
{!! data_get($data, 'description', '') !!}
@php $tagsStr = trim((string) data_get($data, 'tags', '')); $tags = $tagsStr !== '' ? explode(',', $tagsStr) : []; @endphp @if (!empty($tags))
Tags
@foreach($tags as $tag) {{ trim($tag) }} @endforeach
@endif
@if ($pkgId == 7) Précédent @else Précédent @endif
@endsection