Reputation: 1
we have a table where names are like
Hyper Text Markup Language
Cascading Style Sheets
Active Server Pages
Java Server Pages
now we want to search them with short name also like
html
css
asp
jsp
so we created a column for short name, but our laravel query is not working properly, can you help what is the issue with it?
$names = Language::where('short_name','like','%' . $name . '%')
->orWhere('name','like','%' . $name . '%')
->where('public','=',1)
->limit($limit)
->get();
Upvotes: 0
Views: 75
Reputation: 2553
Try this :
$names = Language::where(function( $query){
$query->where('short_name','like','%' . $name . '%')
->orWhere('name','like','%' . $name . '%');
})->where('public','=',1)
->limit($limit)
->get();
Upvotes: 1