jeudi 28 juillet 2016

Laravel - Where Clause not working

I am trying to build a search form with laravel, but I cannot get the where clause to work.

$term = $request->input('term');

$count = DB::table('members as m')
         ->where(DB::raw('m.member_first_name'), 'LIKE', "%$term%")
         ->orWhere(DB::raw('m.member_last_name'), 'LIKE', "%$term%")
         ->orWhere(DB::raw('m.member_business_address'), 'LIKE', "%$term%")
         ->orWhere(DB::raw("concat('m.member_first_name',' ','m.member_last_name')"), 'LIKE', "%$term%")
         ->orWhere(DB::raw("concat('m.member_last_name',' ','m.member_first_name')"), 'LIKE', "%$term%")
         ->orWhere(DB::raw("concat('m.member_name_affix',' ','m.member_last_name',' ','m.member_first_name')"), 'LIKE', "%$term%")
         ->orWhere(DB::raw("concat('m.member_first_name',' ','m.member_name_affix',' ','m.member_last_name')"), 'LIKE', "%$term%")
         ->count();

var_dump($count);



var_dump($count) always returns all the database entries, no matter what the search term is.


This is my first Laravel project and I would be very thankful for any kind of help.

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

Aucun commentaire:

Enregistrer un commentaire