masandikdev
1 year ago

Eloquent Subquery

Posted 1 year ago by masandikdev

Hi, i have model tables like this:

id|name|current|max

1 | campaign 1 | 1 | 10

2 | campaign 2 | 5 | 15

3 | campaign 3 | 10 | 10

4 | campaign 4 | 10 | 20

5 | campaign 5 | 20 | 20

i like to select all campaign that the current is not more than max

Campaign::where('current', '<', 'max')->get();

how to do that with eloquent, i need some light:

Please sign in or create an account to participate in this conversation.