MongoDB
 sql >> Database >  >> NoSQL >> MongoDB

Come posso recuperare il database dei record drom nella vista di modifica in Laravel?

Puoi controllare il tuo foreach se il valore di nameOfDepartment corrisponde a quello del tuo utente.

<div class="form-group">
    <label class="col-md-12">Department</label>
    <div class="col-md-12">
        <select class="custom-select form-control col-md-11" id="department" name="department">
            @foreach($listDepartment as $departmentList)
                @if ($profile->personal_profile['department'] == $departmentList->nameOfDepartment)
                    <option value="{{$departmentList->nameOfDepartment}}" selected="selected">{{$departmentList->nameOfDepartment}}</option>
                @else
                    <option value="{{$departmentList->nameOfDepartment}}">{{$departmentList->nameOfDepartment}}</option>
                @endif
            @endforeach
        </select>
    </div>
</div>

Per il secondo campo di selezione, crea un array con tutti i valori possibili nel controller.

$interview = [
    '' => '--- Select Interciew Mode ---',
    'telephonic' => 'Telephonic',
    'facetoface' => 'Face 2 face',
    'skype' => 'Skype'
];

Quindi puoi fare lo stesso della tua selezione precedente:

<select class="custom-select form-control col-md-12" name="mode" id="mode" required>
    @foreach($interview as $key => $name)
        @if ($profile->personal_profile['interview'] == $key)
            <option value="{{ $key }}" selected="selected">{{ $name }}</option>
        @else
            <option value="{{ $key }}">{{ $name }}</option>
        @endif
   @endforeach
</select>