I have a problem filling out two different selections within the same form in laravel 5.6.7.
vista: registro.blade.php
<div class="form-group">
{{ Form::label('empresa','Empresa:',['class' => 'control-label ']) }
<select class="form-control">
@foreach($empresas as $empresa)
<option value="{{$empresa->id}}">{{$empresa->nombre}}</option>
@endforeach
</select>
</div>
<div class="form-group">
{{ Form::label('modalidad','Modalidad:',['class' => 'control-label ']) }}
<select class="form-control">
@foreach($modalidades as $modalidad)
<option value="{{$modalidad->id}}">
{{$modalidad->nombre_modalidad}}
</option>
@endforeach
</select>
</div>
route: web.php
Route::get('cursos/guardar', ['as' => 'registro',
'uses' => 'CursosController@selectEmpresas']);
Route::get('cursos/guardar', ['as' => 'registro',
'uses' => 'CursosController@selectModalidades']);
Controller: CursosController.php
public function selectEmpresas(Request $request)
{
$empresas = Empresa::all();
return view('cursos.registro',compact('empresas'));//
}
public function selectModalidades()
{
$modalidades = Modalidad::all();
return view('cursos.registro',compact('modalidades'));
}
When I charge the two select I get the following error:
'Undefined variable: companies (View: C: \ xampp \ htdocs \ project-laravel \ resources \ views \ courses \ registry.blade.php) ',
This error appears when I load the two select at the same time, since I tried to load only the company select and it brings me the names of the companies loaded in the table of the database, after this test, comment on the company code and I tried to bring me only a select in this case modality and it brings me perfectly the data of the modalities table, the error only comes out when I charge the two select together. (I hope you understand), I would appreciate it if you could help me as I have fumed the google engine.