Reputation: 241
I want to use something like whereBetween or another to filter created_at in 'accountLog' model using whereRelation
Account::with('accountLog')->get();
how can i do that?
Upvotes: 0
Views: 1903
Reputation: 9117
I think its not available yet if you want to use whereBetween capabilities using whereRelation
Hence, you can achieve same way like this
Account::with('accountLog', function($query) use ($start, $end) {
$query->whereBetween('created_at', [$start, $end]);
})->get();
Upvotes: 3
Reputation: 127
whereBetween is just like where and you can use it the same way :
Account::with('accountLog')->whereBetween('created_at', [$startDate, $endDate])
You should check the doc : https://laravel.com/docs/9.x/queries#additional-where-clauses
Upvotes: 0