Reputation: 543
I am pulling some values ($citylist = User::lists('city');
) from my DB to display them as a dropdown list.
This is my view:
{!!Form::open(array('action' => 'PagesController@menue', 'method' => 'GET', 'style' => 'display: inherit;'))!!}
{!! Form::select('city', $citylist, null, array('class' => 'selectpicker input-group-btn form-control', 'data-style' => 'btn-info btn-info btn-block')) !!}
<span class="input-group-btn">
{!!Form::submit('Submit', array('class' => 'btn btn-info'))!!}
</span>
{!!Form::close()!!}
After submitting the form there is a redirect. I am appending a city name as a query string to the url. So I get something like .../menues/?city=london
.
However, since I am pulling the values with Eloquent's lists()
method the ID is appended to the url instead of the city name.
So I get something like .../menues/?city=1
instead of .../menues/?city=london
.
I need the city name. How can I fix this?
Upvotes: 1
Views: 493
Reputation: 163898
Try to build list like this (I'm using pluck()
since lists()
is deprecated):
$citylist = User::pluck('city', 'city');
Upvotes: 1