@extends('layouts.app')

@section('content')

<div class="container-fluid">
    <div class="row">
        <div class="col">
            <div class="card">
                
                    {{-- Images --}}
                    <div class="card-header">
                        Ajouter des images
                    </div>

                    <div class="card-body">

                        <form method='POST' action="{{ route('image.store') }}" enctype="multipart/form-data">
                            @csrf

                            {{-- Champs caché --}}
                            <input hidden class="form-control" name="bien_id" value="{{ $bienId }}">

                            <div class="row">
                                <div class="col-4">
                                    <input type="file" class="form-control" required name="nom">
                                    <small>Vous ne pouvez pas entrer plus de 10 images pour le même bien</small>
                                </div>
                                <div class="col-5">
                                    <input type="text" class="form-control" required name="commentaire" placeholder="Entrer une légende">
                                </div>
                                <div class="col-3">
                                    <button class="btn btn-sm btn-primary" type="submit">Enregistrer l'image</button>
                                </div>
                            </div>

                            @if(isset($images_bien))
                            <div class="row mt-4">
                                @foreach ($images_bien as $image)
                                    <div class="col-3 mb-5">
                                        <img src="{{ asset('storage/'.$image->nom) }}" style="width: 100%;">
                                    </div>
                                @endforeach
                            </div>
                            @endif
                    
                        </form>

                        <div class="row">
                            <div class="col-12 float-right">
                                <button class="btn btn-primary float-right"><a href="{{ route('questions.vente-location', $bienId) }}">Etape suivante</a></button>
                            </div>
                        </div>

                    </div>

            </div>
        </div>
    </div>
</div>

@endsection