I have a problem trying to fill a select with data from the database, with laravel 5.6
In my controller I have the following code:
public function index()
{
$roles=roleUser::pluck('id_role','nombre');
return view('auth.register',compact('roles') );
}
in my view I have it this way
<select id="id_role" name="id_role" class="form-control">
<option>------Seleccionar------</option>
@foreach($roles as $role)
<option value="{{ $role['id_role'] }}">{{ $role['nombre'] }}</option>
@endforeach
</select>
But when you render it does not show me any data just like this:
<select id="id_role" name="id_role" class="form-control">
<option>------Seleccionar------</option>
<option value=""></option>
<option value=""></option>
<option value=""></option>
<option value=""></option>
<option value=""></option>
<option value=""></option>
<option value=""></option>
<option value=""></option>
</select>