I have a method that invokes the view as follows:
return view('auth.register',[
'teachers' => $this->user->mentors()->lists('name','id'),
]);
And in the view, select
using {{ Form::select() }}
occurs perfectly. The mentors method returns the teachers alphabetically and takes only name
and id
with list
, so far it's obvious.
But I'd like to add option
at the beginning of collection
"Choose a teacher". I did it this way:
collect(['' => 'Escolha um professor'])->merge($this->user->mentors()->lists('name','id'));
But doing so, the value of id
is replaced by index
, as if it were an array.
How can I fix this?