I have a table saves property details, and in the table I store city, suburb, type of property, min and max price, bedrooms and bathrooms.
Now I want to create a search query. If a user only types a city/suburb and leaves the rest of the options blank it should show the search result page according to the properties in that city/suburb. Or the user could type a city and then select type, to give him property type at a chosen city.
Hope you understand what I mean.
So I create this route:
Route::get('/search', 'AdminPropertyController@search_page')->name('search-page');
And this is what I have in the view at the moment
{!! Form::open(['method' => 'GET', 'action'=>'AdminPropertyController@search_page']) !!}
<div class="search-input">
{!! Form::text('city', null, ['class'=>'form-controla', 'placeholder'=>'Search for area,city, or suburb']) !!}
{!! Form::submit('Create User', ['class'=>'btn btn-primary']) !!}
</div>
<div class="select-boxes">
{!! Form::select('type', ['apartment'=>'Type', 'house'=>'House'], null, ['class'=>'form-']) !!}
{!! Form::select('min_price', ['Min Price'=>'Min Price'] + [1=>'1', 20=>'20'], null, ['class'=>'form-']) !!}
{!! Form::select('maxprice', ['Max Price'=>'Max Price'] + [1=>'1', 20=>'20'], null, ['class'=>'form-']) !!}
{!! Form::select('bedrooms', [''=>'Bedrooms'] + [2=>'1+', 3=>'2+'], null, ['class'=>'form-']) !!}
{!! Form::select('bathrooms', [''=>'bathrooms'] + [2=>'1+', 3=>'2+'], null, ['class'=>'form-']) !!}
</div>
{!! Form::close() !!}
I used this in the first input
{!! Form::text('city', null, ['class'=>'form-controla', 'placeholder'=>'Search for area,city, or suburb']) !!}
But actually there I want to search for either city or suburb
At the moment my method looks blank because I have no idea how to do that.
public function search_page(Request $request){
// to complete
}
Has anyone done anything of that nature?
Hope someone can help