@php $r = $room ?? null; @endphp
<div class="row">
    <div class="col-md-6"><div class="form-group">
        {!! Form::label('name', __('medorganization::lang.room') . ':*') !!}
        {!! Form::text('name', $r->name ?? null, ['class' => 'form-control', 'required', 'maxlength' => 100]) !!}
    </div></div>
    <div class="col-md-3"><div class="form-group">
        {!! Form::label('code', __('medorganization::lang.code') . ':') !!}
        {!! Form::text('code', $r->code ?? null, ['class' => 'form-control', 'maxlength' => 20]) !!}
    </div></div>
    <div class="col-md-3"><div class="form-group">
        {!! Form::label('department_id', __('medorganization::lang.department') . ':*') !!}
        {!! Form::select('department_id', $departments, $r->department_id ?? null, ['class' => 'form-control medorg-select2', 'placeholder' => __('messages.please_select'), 'required']) !!}
    </div></div>
</div>
<div class="row">
    <div class="col-md-3"><div class="form-group">
        {!! Form::label('room_type', __('medorganization::lang.room_type') . ':*') !!}
        <select name="room_type" class="form-control" required>
            @foreach($roomTypes as $type)
                <option value="{{ $type }}" @if(($r->room_type ?? 'other') === $type) selected @endif>{{ __('medorganization::lang.room_type_' . $type) }}</option>
            @endforeach
        </select>
    </div></div>
    <div class="col-md-3"><div class="form-group">
        {!! Form::label('floor', __('medorganization::lang.floor') . ':') !!}
        {!! Form::number('floor', $r->floor ?? null, ['class' => 'form-control']) !!}
    </div></div>
    <div class="col-md-3"><div class="form-group">
        {!! Form::label('capacity', __('medorganization::lang.capacity') . ':') !!}
        {!! Form::number('capacity', $r->capacity ?? null, ['class' => 'form-control', 'min' => 0]) !!}
    </div></div>
    <div class="col-md-3"><div class="form-group">
        {!! Form::label('status', __('medorganization::lang.status') . ':*') !!}
        <select name="status" class="form-control" required>
            @foreach($statuses as $status)
                <option value="{{ $status }}" @if(($r->status ?? 'available') === $status) selected @endif>{{ __('medorganization::lang.room_status_' . $status) }}</option>
            @endforeach
        </select>
    </div></div>
</div>
<div class="form-group">
    {!! Form::label('equipment', __('medorganization::lang.equipment') . ':') !!}
    {!! Form::text('equipment', $r && is_array($r->equipment) ? implode(', ', $r->equipment) : null, ['class' => 'form-control', 'placeholder' => __('medorganization::lang.equipment_help')]) !!}
</div>
<div class="checkbox"><label>{!! Form::checkbox('scheduling_enabled', 1, (bool) ($r->scheduling_enabled ?? false)) !!} @lang('medorganization::lang.scheduling_enabled')</label></div>
