mardi 25 juillet 2017

Search using words in any order or combination and return row

My table has a row that is stored as D1234 HEX SCREW GS0090 O109. Currently I can do something like this D1234 HEX or SCREW GS0090 and it will return the row. However I want to be able to enter words in any combination or any order like D1234 GS0090or HEX D1234 and have it return this row. How can this be done?

$products = DB::connection('it')
            ->table('it')
            ->join('units','units.code', '=', 's.code')
            ->join('vendors', 'vendors.code', '=', 's.code')
            ->where('s.deleted', '=', 0)
            ->where('vendors.deleted', '=', 0)
            ->where('s.description', 'LIKE', '%'.$term.'%')
            ->orWhere('s.vendorcode', 'LIKE', '%'.$term.'%' )
            ->orWhere('s.vendordefaultcode','LIKE', '%'.$term.'%')
            ->orWhere('vendors.partnumber', 'LIKE', '%'.$term.'%')
            ->orWhere('vendors.partvendorcode', 'LIKE', '%'.$term.'%')
            ->get());



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire