@php
    // Variable for the form
    $form = 'destinationFormID';
    $button = [
        'save' => 'destinationSaveData',
        'close' => 'destinationCloseForm',
    ];

    // Get data
    $id = !empty($data) && !empty($data['id']) ? (int) $data['id'] : 0;
    $name = !empty($data) && !empty($data['name']) ? ucfirst($data['name']) : '';
    $destinationtypeID = !empty($data) && !empty($data['destinationtype_id']) ? (int) $data['destinationtype_id'] : '';

    // Form title
    $title = !empty($id) ? $name : 'Ajouter une destination';

@endphp

<form id="{{ $form }}">
    @csrf
    <input type="hidden" name="rowID" value="{{ $id }}">
    <div class="modal-header bg-primary">
        <h3 class="modal-title fw-light text-uppercase text-white fs-5">{{ $title }}</h3>
        <!--begin::Close-->
        <div class="btn btn-icon btn-sm  ms-2" data-bs-dismiss="modal" aria-label="Close">
            <i class="ki-duotone ki-cross fs-1 text-white"><span class="path1"></span><span class="path2"></span></i>
        </div>
        <!--end::Close-->
    </div>

    <div class="modal-body">
        <!--begin::Input-->
        <div class="fv-row mb-5 row">
            <div class="col-md-6">
                <!--begin::Label-->
                <label class="d-flex align-items-center fs-5 fw-semibold mb-2">
                    <span class="required">Type de destination</span>
                    </span>
                </label>
                <!--end::Label-->
                <select class="form-select form-select-solid" id="destinationtype_id" data-control="select2"
                    data-placeholder="Choix..." data-dropdown-parent="#destinationModalID" name="destinationtype_id">
                    <option></option>
                    @forelse ($destinationTypeRecords as $destinationTypeRecord)
                        @php
                            $selected = $destinationTypeRecord->id === $destinationtypeID ? ' selected="selected"' : '';
                        @endphp
                        <option value="{{ $destinationTypeRecord->id }}" {{ $selected }}>{{ ucfirst($destinationTypeRecord->name) }}
                        </option>
                    @empty
                    @endforelse
                </select>
            </div>
            <div class="col-md-6">
                <!--begin::Label-->
                <label class="d-flex align-items-center fs-5 fw-semibold mb-2">
                    <span class="required">Destination</span>
                    </span>
                </label>
                <!--end::Label-->
                <!--begin::Input-->
                <input type="text" class="form-control form-control-lg form-control-solid" name="name"
                    value="{{ $name }}">
                <!--end::Input-->
            </div>
        </div>
        <!--end::Input-->



    </div>
    <div class="modal-footer justify-content-center">
        <a href="javascript:;" class="btn btn-danger" data-bs-dismiss="modal" aria-label="Close"
            id="{{ $button['close'] }}">Fermer</a>
        <button type="submit" class="btn btn-primary" id="{{ $button['save'] }}">Ajouter</button>
    </div>
</form>
