vendredi 27 janvier 2017

Check lowercase and uppercase search

I'm using this query:

  public function autocomplete(Request $request)
   {
      $company_name = $request->input('query');
      $data = BusinessUser::where("company_name","LIKE",'%'. $company_name .'%')->pluck('company_name');
      return response()->json($data);
   }

In database for company name i can have this: 'Test','TEST','test'. So how can i check all of this so that i get result. Any suggestion?

I tried this but then i get an error that i need to pass array:

  $data = BusinessUser::whereRaw("company_name","LIKE",'%'. $company_name .'%')->orWhereRaw("company_name","LIKE",'%'. $company_name .'%')->pluck('company_name');



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire