{{-- resources/views/points/public_show.blade.php --}} @extends('layouts.base') @push('styles') @endpush @php $token = $p->serial ?? null; $favoriteIds = []; if (auth()->check()) { // Récupère les IDs de points favoris de l'utilisateur connecté $favoriteIds = auth()->user() ->favoritePoints() ->pluck('points.id') // ou ->pluck('point_id') selon ta relation ->all(); } $isVisible = $p->is_visible ?? false; @endphp @section('title', isset($p?->name) ? ($p->name . (isset($p->serial) ? ' — '.$p->serial : '')) : __('Waypoint')) @php use Illuminate\Support\Str; use Illuminate\Support\Facades\Storage; $pt = $p ?? $point ?? null; $point = $pt; $locale = app()->getLocale(); $readonly = (bool)($readonly ?? false); if (count($availablePins) < 2) $pt->pin_icon = 'green_pin.png'; $photos = $p->photos ?? collect(); $canShare = auth()->check() && (int)auth()->id() === (int)$pt->user_id; // Icône actuelle (nom de fichier) $currentPin = $point?->pin_icon ?: 'green_pin.png'; // Contexte /wp/{token} (token public) ? $isTokenMode = request()->routeIs('points.public') || Str::contains(url()->current(), '/wp/'); // URL POST de sauvegarde d’icône (⚠️ routes doivent exister) $pinPostUrl = $isTokenMode ? route('points.pin.update.token', ['locale' => $locale, 'token' => $point->serial]) : route('points.pin.update.id', ['locale' => $locale, 'point' => $point->id]); // Liste des fichiers pin (fallback si le contrôleur n’a pas fourni) $pins = ($pins ?? $availablePins ?? null) ?: [ 'red_pin.png','green_pin.png','blue_pin.png','yellow_pin.png','purple_pin.png','orange_pin.png' ]; // Normalise les points pour la carte (et construit pin_url) $mapPoints = collect($mapPoints ?? [])->map(function($mp){ $mp = is_array($mp) ? (object)$mp : $mp; $file = $mp->pin_icon ?? 'green_pin.png'; $mp->pin_url = $mp->pin_url ?? asset('assets/pins/'.$file).'?v='.now()->timestamp; $mp->latitude = (float)($mp->latitude ?? 0); $mp->longitude = (float)($mp->longitude ?? 0); return $mp; })->values()->all(); $fullAddress = ''; if ($pt) { $parts = [ $pt->address1 ?? null, $pt->address2 ?? null, $pt->postcode ?? null, $pt->city ?? null, $pt->country_isocode ?? null, ]; $fullAddress = trim(implode(' ', array_filter($parts, fn($v) => is_string($v) && $v !== ''))); } @endphp {{-- Bottom Nav --}} {{-- 'bottomInfo' => [ 'label' => __('More informations'), 'target' => '#waypoint-details', // un id dans la page ], --}} @include('partials.bottom_nav', [ 'bottomTabs' => [ [ 'icon' => "to_picto.svg", 'label' => __('Join'), 'drawer' => 'maps', // ouvre le tiroir "maps" ], $canShare ? [ 'icon' => "sharing_picto.svg", 'label' => __('Sharing'), 'drawer' => 'share', ] : [ 'icon' => "sharing_picto.svg", 'label' => __('Sharing'), 'href' => lr('login'), ], [ 'icon' => "myV_picto.svg", 'label' => __('My waypoints'), 'href' => lr('search'), 'primary' => false, ], ], ]) @section('head') {{-- Meta CSRF correcte --}} {{-- Leaflet CSS (une seule fois) --}} @endsection @section('content') @if(!$pt)
{{ __('This waypoint does not exist or is no longer available.') }} {{ __('Token:') }} {{ $serialToken ?? '—' }}
@if($readonlyUrl)

{{ __('Open read-only view') }}

@endif
@return @endif {{--
--}}
{{-- Bouton More informations ATTACHÉ à la carte --}}
{{--
--}}
{{-- Carte --}} {{-- CONTENU EN DESSOUS --}}
{{--
@csrf {{--

{{ __('Choose a pin icon') }}

--}} {{--
@foreach($pins as $fn) @endforeach
--}} {{--
{{ $pt->name }} : {{ $pt->serial }}
--}} {{-- Favori (seulement si token présent) --}} @auth @if($serialToken) @php $token = $pt->serial ?? null; $isFav = auth()->check() && in_array($pt->id, $favoriteIds, true); @endphp @endif @endauth
{{ $pt->name }}
{{ $pt->serial }}
{{-- @if($pt && $pt->latitude && $pt->longitude) @endif --}} {{-- @endif --}} {{-- ========================================================= = PHOTOS = ========================================================= --}}
{{--

{{ __('Media') }}

--}} @php $photos = $pt->photos ?? collect(); $mainPhotoPath = $photos->first()->path ?? null; $mainPhotoUrl = $mainPhotoPath ? Storage::disk('public')->url($mainPhotoPath) : null; @endphp {{--
--}} {{-- GALLERY / PHOTOS --}} @auth @if($photos->isNotEmpty()) @endif {{-- Lightbox plein écran --}}
count() >= 4) style="display:none" @endif>
@csrf @method('PUT')
@endauth {{--
--}}
{{--
{{--

{{ __('QR Code') }}

--}} {{--
@if($qrUrl) QR Code @else
{{ __('QR code unavailable') }}
@endif
--}}
{{-- ---------------------------------- Messages flash ---------------------------------- --}} @if (session('status'))
{{ session('status') }}
@endif @if ($errors->any())
{{ __('Errors') }} :
    @foreach ($errors->all() as $error)
  • {{ $error }}
  • @endforeach
@endif {{-- ---------------------------------- Edit form ---------------------------------- --}}
@if($pt && !empty($pt->serial) && $serialToken)
@csrf @method('PUT')
@if(count($availablePins) > 1) @foreach($availablePins as $fn) @endforeach @else @endif
@php $user = auth()->user(); $canEditPrivacy = $user && ( (int)$user->role_id === 1 || // Super Admin (int)$user->role_id === 2 || // Admin Pro (int)$user->id === (int)$p->user_id // Owner ); @endphp
{{--
--}}
{{-- --}}
{{--
--}}
{{ __('Password') }}
{{-- value="{{ old('password', $pt->password) }}" --}}
{{ __('Cancel') }}
@auth
@csrf @method('DELETE')
@endauth @endif
{{-- Liste des partages --}}
@if(isset($p) && $p->sharings && $p->sharings->isNotEmpty())
{{ __('Owner') }}
{{ $pt->owner->lastname ?? '' }} {{ $pt->owner->firstname ?? '' }} ({{ $pt->owner->email ?? '' }})
{{ __('Shared with') }}
    @foreach($p->sharings as $share) @php $target = $share->target; $label = null; if ($target) { $label = trim(($target->firstname ?? '').' '.($target->lastname ?? '')); if ($label === '') { $label = $target->email; } elseif (!empty($target->email)) { $label .= ' ('.$target->email.')'; } } elseif (!empty($share->recipient_email)) { $label = $share->recipient_email; } else { $label = __('Unknown recipient'); } @endphp
  • {{ $label }}
    @csrf
  • @endforeach
@endif
{{-- LIGHTBOX FULLSCREEN --}} @push('scripts') @endpush @push('scripts') @endpush @endsection