@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">{{ __('Dashboard') }}</div>

                <div class="card-body">
                    @if (session('status'))
                        <div class="alert alert-success" role="alert">
                            {{ session('status') }}
                        </div>
                    @endif

                    <div class="row">
                        <div class="col-sm-12 mt-4">
                            <form>
                            <label for="price_min">Min prix:</label><input type="number" name="filter[price_min]" id="price_min">
                            <label for="price_max">Max prix:</label><input type="number" name="filter[price_max]" id="price_max">
                                <button class="btn btn-secondary" type="submit">Rechercher</button>
                            </form>
                        </div>
                    @if(count($homes) > 0)
                    @foreach($homes as $home)
                        <div class="col-sm-6">
                            <div class="card">
                                <img class="card-img-top" src="{{ asset($home->pictures[0]) }}">
                                <div class="card-body">
                                    <h5 class="card-title">{{ $home->title }}</h5>
                                    <p class="card-text">{{ $home->excerpt() }}</p>
                                    <a href="{{ route('home.show', ['id' => $home->id]) }}" class="btn btn-primary">Voir la maison</a>
                                </div>
                            </div>
                        </div>
                    @endforeach
                    <div class="col-sm-12 mt-4">
                        {{ $homes->links() }}
                    </div>
                    @else
                        Aucune maison enregistrée :(
                    @endif
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection