How To Retrieve Old Data Within The View() Instead Of Redirect() In Laravel (v5.*)

** lets say you have a dropdown menu where you select the city, town & you want to get all the products under this town,
so instead of the town selected item gets reseted back to the first item in the dropdown menu, we can now presist through the url query-string without to much work.

1- in your search controller

$search_result = // your querie ;
return view('the.view',compact('search_result'));

2- in the search view


{{ Form::select(
  $something->lists('name', 'id'),
  $request->town_id // this is how we get the current query

{{-- $search_result --}}

now the dropdown will select the option that equal to the query in the url, if not it will be null.

if u have dynamic dropdown, use the above in conjunction with Dynamic Dropdown With Form Data Binding Laravel


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s