Skip to content

Instantly share code, notes, and snippets.

@codeyash
Forked from leocavalcante/eloquent_example.php
Created March 17, 2014 12:10
Show Gist options
  • Save codeyash/9598161 to your computer and use it in GitHub Desktop.
Save codeyash/9598161 to your computer and use it in GitHub Desktop.
<?php
Quota::with(
array(
'codes' => function($query) {
$query->where('number', '=', 11);
}
)
)
->where('label', '=', 'foo')
->whereRaw('quotas.count < quotas.limit')
->orderBy('count')
->orderBy('id', 'desc')
->get();
Select *
From quotas as q
Join codes as c
on (c.quotaId = q.id)
Where
q.label = 'foo' and
c.number = 11 and
q.count < q.limit
Order by
q.count asc,
q.id desc;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment