
@extends('adminlte::page')

@section('title', 'Immobili')

@section('content_header')
    <h1>Immobili</h1>
@stop

@section('content')
    <p>Elenco immobili</p>
    <a href="{{ route('immobili.create') }}" class="btn btn-primary mb-3">Nuovo Immobile</a>

    <table class="table table-bordered table-striped">
        <thead>
            <tr>
                <th>ID</th>
                <th>Indirizzo</th>
                <th>Città</th>
                <th>Stato</th>
                <th>Azioni</th>
            </tr>
        </thead>
        <tbody>
            @foreach($immobili as $immobile)
                <tr>
                    <td>{{ $immobile->id }}</td>
                    <td>{{ $immobile->indirizzo }}</td>
                    <td>{{ $immobile->citta }}</td>
                    <td>{{ $immobile->stato }}</td>
                    <td>
                        <a href="{{ route('immobili.show', $immobile->id) }}" class="btn btn-info btn-sm">Visualizza</a>
                        <a href="{{ route('immobili.edit', $immobile->id) }}" class="btn btn-warning btn-sm">Modifica</a>
                        <form action="{{ route('immobili.destroy', $immobile->id) }}" method="POST" style="display:inline;">
                            @csrf
                            @method('DELETE')
                            <button type="submit" class="btn btn-danger btn-sm" onclick="return confirm('Sei sicuro di voler eliminare questo immobile?')">Elimina</button>
                        </form>
                    </td>
                </tr>
            @endforeach
        </tbody>
    </table>
@stop
