<form action="{{ route('visitorLogs.update', $visitorLog->id) }}" method="POST">
    @csrf
    @method('PUT')
    <div class="mb-3">
        <label for="staff_id" class="form-label">Staff</label>
        <select name="staff_id" id="staff_id" class="form-select" required>
            @foreach ($staff as $staffMember)
                <option value="{{ $staffMember->id }}" {{ $staffMember->id == $visitorLog->id_staff ? 'selected' : '' }}>
                    {{ $staffMember->name }}
                </option>
            @endforeach
        </select>
    </div>

    <div class="mb-3">
        <label for="visitor_id" class="form-label">Visitor</label>
        <select name="visitor_id" id="visitor_id" class="form-select" required>
            @foreach ($visitors as $visitor)
                <option value="{{ $visitor->id }}" {{ $visitor->id == $visitorLog->id_visitor ? 'selected' : '' }}>
                    {{ $visitor->name }}
                </option>
            @endforeach
        </select>
    </div>

    <div class="mb-3">
        <label for="plate_no" class="form-label">Plate No</label>
        <input type="text" name="plate_no" id="plate_no" class="form-control" value="{{ old('plate_no', $visitorLog->plate_no) }}" required>
    </div>

    <div class="mb-3">
        <label for="guard_in_id" class="form-label">Guard (Arrive)</label>
        <select name="guard_in_id" id="guard_in_id" class="form-select" required>
            @foreach ($guards as $guard)
                <option value="{{ $guard->id }}" {{ $guard->id == $visitorLog->guard_in_id ? 'selected' : '' }}>
                    {{ $guard->name }}
                </option>
            @endforeach
        </select>
    </div>

    <div class="mb-3">
        <label for="guard_out_id" class="form-label">Guard (Depart)</label>
        <select name="guard_out_id" id="guard_out_id" class="form-select" required>
            @foreach ($guards as $guard)
                <option value="{{ $guard->id }}" {{ $guard->id == $visitorLog->guard_out_id ? 'selected' : '' }}>
                    {{ $guard->name }}
                </option>
            @endforeach
        </select>
    </div>

    <div class="mb-3">
        <label for="purpose" class="form-label">Purpose</label>
        <input type="text" name="purpose" id="purpose" class="form-control" value="{{ old('purpose', $visitorLog->purpose) }}" required>
    </div>

    <div class="mb-3">
        <label for="total_visitor" class="form-label">Total Visitor</label>
        <input type="number" name="total_visitor" id="total_visitor" class="form-control" value="{{ old('total_visitor', $visitorLog->total_visitor) }}" required>
    </div>

    <div class="mb-3">
        <label for="arrive_at" class="form-label">Arrive Time</label>
        <input type="datetime-local" name="arrive_at" id="arrive_at" class="form-control" 
               value="{{ old('arrive_at', \Carbon\Carbon::parse($visitorLog->arrive_at)->format('Y-m-d\TH:i')) }}" required>
    </div>
    
    <div class="mb-3">
        <label for="depart_at" class="form-label">Depart Time</label>
        <input type="datetime-local" name="depart_at" id="depart_at" class="form-control" 
               value="{{ old('depart_at', $visitorLog->depart_at ? \Carbon\Carbon::parse($visitorLog->depart_at)->format('Y-m-d\TH:i') : '') }}">
    </div>

    <button type="submit" class="btn btn-primary">Update</button>
</form>
