I'm working on Laravel framework version 5.1
How do I select all of my rows from an eloquent model where his abc
column equals to a
or b
or c
?
Sorry if I haven't explained myself very well.
You just chain the conditions:
App\SomeModel::where('abc', 'a')->orWhere('abc', 'b')->orWhere('abc', 'c')->get();
Or as an alternative you can use whereIn
for more compact solution:
App\SomeModel::whereIn('abc', ['a', 'b', 'c'])->get();
Which checks if the value of the abc
column is present in the array passed.
You can check out the Laravel documentation for more info on using Where Clauses.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With