mardi 5 juillet 2016

laravel multi-field search form

have a multi-field search form in my Laravel 5.2 app

price 
rooms 
type 
rent

i have some thing wrong my result no correct i think because im using orWhere(). i want AND between input fields. i want any solution for this

public function search()
    {

        $un_price = \Request::get('un_price');
        $un_rooms = \Request::get('un_rooms');
        $un_type = \Request::get('un_type');
        $un_rent = \Request::get('un_rent');
        $units = DB::table('units')->whereIn('un_status', [1])
            ->where('un_price','like','%'.$un_price.'%')
            ->orWhere("un_rooms", "LIKE", "%$un_rooms%")
            ->orWhere("un_type", "LIKE", "%$un_type%")
            ->orWhere("un_rent", "LIKE", "%$un_rent%")
            ->paginate(20);
        return view('home.units.show', compact('units'));
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire