@extends('layouts.app')

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

    <form action="{{ route('clients.update',$client) }}" method="POST">
        @csrf @method('PUT')

        <div class="mb-3">
            <label>Nombre</label>
            <input name="nombre" value="{{ $client->nombre }}"
                   class="form-control" required>
        </div>

        <div class="mb-3">
            <label>Email</label>
            <input type="email" name="email"
                   value="{{ $client->email }}"
                   class="form-control" required>
        </div>

        <div class="mb-3">
            <label>Teléfono</label>
            <input name="telefono"
                   value="{{ $client->telefono }}"
                   class="form-control">
        </div>

        <div class="mb-3">
            <label>Dirección</label>
            <input name="direccion"
                   value="{{ $client->direccion }}"
                   class="form-control">
        </div>

        <div style="display: none" class="mb-3">
            <label>Empresa</label>
            <select name="company_id" class="form-control" required>
                @foreach($companies as $company)
                    <option value="{{ $company->id }}"
                        @selected($client->company_id == $company->id)>
                        {{ $company->nombre }}
                    </option>
                @endforeach
            </select>
        </div>

        <button class="btn btn-success">Actualizar</button>
        <a href="{{ route('clients.index') }}" class="btn btn-secondary">Cancelar</a>
    </form>
</div>
@endsection
