burtonLowel
burtonLowel

Reputation: 794

Laravel: Using multiple search terms to get an entry

Right now, I am grabbing users who fit a certain criteria like this:

$searchTerm = 'MULTI';
$multiUser = USER::where('code', 'LIKE', '%'.$searchTerm.'%')->get();

Now I changed the code to be "MANY" but we have a lot of users who already have MULTI as their code so I need the searchTerm to grab both. Can I do this in one query?

Upvotes: 1

Views: 34

Answers (1)

Musa
Musa

Reputation: 1379

User::query()
->where('code', 'LIKE', '%MULTI%')
->orWhere('code', 'LIKE', '%MANY%')
->get();

Upvotes: 1

Related Questions