@extends('layouts.app')

@section('content')
<div class="container">
    <h2>Clientes</h2>

    <a href="{{ route('clients.create') }}" class="btn btn-primary mb-3">
        Nuevo Cliente
    </a>

    <table class="table table-bordered">
        <thead>
            <tr>
                <th>ID</th>
                <th>Nombre</th>
                <th>Email</th>
                <th>Empresa</th>
                <th>Acciones</th>
            </tr>
        </thead>
        <tbody>
            @foreach($clients as $client)
            <tr>
                <td>{{ $client->id }}</td>
                <td>{{ $client->nombre }}</td>
                <td>{{ $client->email }}</td>
                <td>{{ $client->company->nombre }}</td>
                <td>
                    <a href="{{ route('clients.edit',$client) }}"
                       class="btn btn-warning btn-sm">Editar</a>

                    <form action="{{ route('clients.destroy',$client) }}"
                          method="POST" class="d-inline">
                        @csrf @method('DELETE')
                        <button class="btn btn-danger btn-sm"
                          onclick="return confirm('¿Eliminar cliente?')">
                          Eliminar
                        </button>
                    </form>
                </td>
            </tr>
            @endforeach
        </tbody>
    </table>
</div>
@endsection
