i´m traying to get of my DB to lowercase column data with model::where
this is my query:
$restaurants = Restaurant::where('name', 'LIKE', "%".$search."%")->get();
$results = [];
foreach ($restaurants as $r) {
$data = array(
'id' => $r->id,
'label' => $r->name,
'value' => $r->name,
'url' => $r->url,
);
array_push($results, $data);
}
i´m traying with this:
$restaurants = Restaurant::whereRaw('LOWER(name) = ?', [$search])->get();
but return empty results.
How i would can to do this?. In my database it´s all in uppercase i need search in uppercase or lowercase
Thanks for help
My Answer:
'%pizza%')->get();
foreach($restaurants as $restaurant){
$restaurant->name = strtolower($restaurant->name);
$restaurant->save();
}
Rate this post
3 of 5 based on 2504 votesComments