@extends('layouts.app')
@section('title', 'Gestion des lits')
@section('content')
Gestion des lits
Organisez les lits de vos chambres dortoirs.
{{-- ⚠️ Warning surcapacité (legacy data) --}}
@if($overCapacity->count() > 0)
⚠️ Chambre(s) en surcapacité détectée(s)
Les chambres suivantes contiennent plus de lits que leur capacité ne le permet :
@foreach($overCapacity as $r)
-
{{ $r->name }} : {{ $r->beds_count }} lit(s) pour une capacité de {{ $r->max_capacity }}
(à supprimer : {{ $r->beds_count - $r->max_capacity }})
@endforeach
@endif
{{-- Erreurs globales (validation backend) --}}
@if($errors->any())
@foreach($errors->all() as $e)
• {{ $e }}
@endforeach
@endif
{{-- Succès flash --}}
@if(session('success'))
✅ {{ session('success') }}
@endif
{{-- ─── Aucune chambre dortoir ─── --}}
@if($dormitories->isEmpty())
🛏️
Aucune chambre dortoir
Créez d'abord une chambre de type dortoir avant d'ajouter des lits.
+ Créer une chambre
@else
{{-- ─── Sections par chambre ─── --}}
@foreach($dormitories as $room)
@php
$isFull = $room->beds_count >= $room->max_capacity;
$isOver = $room->beds_count > $room->max_capacity;
$remaining = max(0, $room->max_capacity - $room->beds_count);
@endphp
{{-- Header chambre --}}
🛏️
{{ $room->name }}
Capacité maximale : {{ $room->max_capacity }} lit(s)
@if($isOver)
⚠️ Surcapacité : {{ $room->beds_count }}/{{ $room->max_capacity }}
@elseif($isFull)
🔒 Pleine ({{ $room->beds_count }}/{{ $room->max_capacity }})
@else
✅ {{ $room->beds_count }}/{{ $room->max_capacity }} lits ({{ $remaining }} restant(s))
@endif
{{-- Liste des lits --}}
@if($room->beds->isEmpty())
Aucun lit pour le moment. Ajoutez le premier ↓
@else
| Nom du lit |
Statut |
Actions |
@foreach($room->beds as $bed)
| {{ $bed->name }} |
{{ $bed->is_enabled ? '✅ Actif' : '❌ Désactivé' }}
|
|
@endforeach
@endif
{{-- Footer : bouton ajouter --}}
@if($isFull || $isOver)
@else
@endif
@endforeach
@endif
{{-- Form caché pour soumettre l'ajout --}}
@push('scripts')
@endpush
@endsection