Reputation: 3833
I have a variable $a
which is an integer.
Then I have a table with a row called MaxValue
.
I want to do an eloquent query to find the first MaxValue ocurrence bigger than $a
.
I can do it easily with SQL but I would rather do it correctly with Eloquent.
Something like this:
Item::where('MaxValue', '>=',$a)->first();
Upvotes: 0
Views: 26
Reputation: 885
You can try something like this:
Item::where('MaxValue', '>=', $a)->order_by('MaxValue', 'desc')->first();
Upvotes: 1