mercredi 5 décembre 2018

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

I have 2 Tables in Larvel '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']);`enter code here`

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();
        dd($results);
        return View::make('searchfilter', ['results' => $results]);
    }



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2KWjyCp
via IFTTT

Aucun commentaire:

Enregistrer un commentaire