<form id="form-fee-edit">

    <input type="hidden" value="{{ $fee->id }}" name="id">
    <div class="form-group">
        <label>Tên</label>
        <div>
            <input type="text" name="name" class="form-control"
                   id="name" value="{{ $fee->name }}">
        </div>
    </div>
    <div class="form-group">
        <label>Giá trị</label>
        <div>
            <input type="text" name="fee" class="form-control"
                   id="fee" value="{{ $fee->fee }}">
        </div>
    </div>
    <div class="form-group">
        <label>Nhà trọ</label>
        <div>
            <select class="form-control select2" name="hostel_id" id="hostel_id_2">
                <option>Vui lòng chọn giá trị</option>
                @foreach($hostels as $hostel)
                    <option @if($hostel->id == $fee->hostel_id) selected=""
                            @endif value="{{ $hostel->id }}">{{ $hostel->name }}</option>
                @endforeach
            </select>
        </div>
    </div>
    <div class="form-group">
        <label>Phòng trọ</label>
        <div>
            <select class="form-control select2" name="room_id" id="room_id_2" multiple>

                @php $rooms = json_decode($fee->rooms, true);@endphp

                @if (is_array($rooms)) {
                @foreach($rooms as $room)
                    @php $roomItem = \App\Models\Room::find($room); @endphp
                    @if($roomItem)
                        <option selected="" value="{{ $roomItem->id }}">{{ $roomItem->name }}</option>
                    @endif
                @endforeach
                @endif

            </select>
        </div>
    </div>

</form>