I'm trying to short records(tours) according to price (high to low and low to high) in search page, with a form that has submits on change event. Below is the code for the form:
{!!Form::open(['route' => 'short','method' => 'GET', 'role' => 'search','class'=>'select-filters'])!!}
<input type="hidden" name="country" value="{{$country}}">
<input type="hidden" name="category" value="{{$category}}">
<input type="hidden" name="days" value="{{$days}}">
<select name="sort_price" id="sort-price" onchange="this.form.submit()">
<option value="" selected="">Sort by price</option>
<option value="lower">Lowest price</option>
<option value="higher">Highest price</option>
</select>
{!! Form::close() !!}
and I've initialized the values in the same page but give the error htmlspecialchars() expects parameter 1 to be string, array given:
@if(Request::only('country') != null)
{{$country = Request::only('country')}}
@else
{{ $country = null }}
@endif
@if(Request::only('category') != null)
{{$category = Request::only('category')}}
@else
{{ $category = null }}
@endif
@if(Request::only('days') != null)
{{$days = Request::only('days')}}
@else
{{ $days = null }}
@endif
The values in Request::only() is being passed from the search form in index page. When I die and dump:
{{dd(Request::only('country','category','days'))}}
I throws the incoming value in array form
It dumps individual key value pair if i pass only one argument:
{{dd(Request::only('country'))}}
or
{{dd(Request::only('category'))}}
or
{{dd(Request::only('days'))}}