Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

I have 2 Tables in Laravel 'properties' & 'categories', and i want to filter data by search form, how i will display data after filter

I have 2 Tables in Laravel 'properties' & 'categories', and i want to filter data by search form, how i will display data after filter. Basically there are 2 tables in my database and I want to use filter, I have already created a form. If i will submit the form then I want to display the data from 'properties' (Table Name) and 'categories' (Table Name) table. Please help me to display this data. I am using laravel 5.7.

Here is my route:

Route::post('search-by-filter',['uses'=>'HomeController@searchPropertyFilter', 'as'=>'searchfilter.property']);

and here is my Homecontroller.php

public function searchPropertyFilter(Request $r){
        $search = '%'.Input::get('search').'%';
        $pages  = DB::table('properties')
                        ->select('properties.property_title', 'properties.minprice', 'properties.maxprice', 'properties.max_area', 'properties.property_size', 'properties.bedroom', 'properties.bathroom')
                        ->where('property_title', 'LIKE', $search);

        $blogitems  = DB::table('categories')
                        ->select('categories.id', 'categories.category_name')
                        ->where('id', 'LIKE', $search);
        $results = $pages->union($blogitems)->take(30)->get();
        return View::make('searchfilter', ['results' => $results]);
    }

Comments