如何将 select box html 转换为 html collactive

how to convert select box html to form html collactive

嗨,我的控制器里有这个

$listPatient = Patient::get();

    return view('backend.consultations.create')->with([
        'patient' => $this->patient,
        'patient_id' =>$this->patient_id,
        'listPatient' => $listPatient,
        ]);

在我看来我有

<div class="form-group">

    <div class="col-md-2">
        List clients
    </div>
    <div class="col-lg-10">

         <select name="patient_id">
            <option value="0">Veillier séléctionner un patien </option>
            @foreach($listPatient as $key)
              <option value="{{$key->id}}">{{$key->nom_patient}} {{$key->prenom_patient}}</option>
            @endforeach
        </select> 
    </div><!--col-lg-10-->
</div><!--form control-->

它工作正常,我想使用 Form::select 但它不工作,谁能帮助我吗

在您的控制器中,您需要获取以下内容 $listPatient

$listPatient = Patient::lists("nom_patient","id")->toArray();

在你看来你会想要

{!! Form::select('patient_id', [0 => 'Veillier séléctionner un patien'] + $listPatient, null) !!}

一个简单的解决方案

enter code here :    <div class ="form-group">
            {{ Form::label('list_patient', trans('validation.attributes.backend.consultations.nom_patient'), ['class' => 'col-lg-2 control-label required']) }}
            <div class="col-lg-10">
            <select id="patient_id" name="patient_id" class="form-control select2 box-size" required="required" placeholder=" Non définie" >
            <option value="">Non définie</option>
                @foreach($listPatient as $key)

                    <option value ="{{$key->id}}">{{$key->nom_patient}} {{$key->prenom_patient}}</option>
                @endforeach
                </select>
            </div><!--col-lg-3-->
    </div><!--form control-->