Looks like eager load constraints may be what you are looking for.
http://laravel.com/docs/eloquent#eager-loading
Example:
$user = User::with(array('posts' => function($query) { $query->whereBetween('created_at',array('2014-02-20 00:00:00','2014-02-21 23:59:59')); }))->find(1);
I was not able to test the code but hope this helps point you in the right direction.
thank you michaeldeol, but with your solution, only get the users with posts between dates, and i need get all users.
I forgot the parenthesis, with $user->posts()->where........
it works!!!
Thank you!!
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community