I try to get records on relation when there is only one record in the one to many relation and only the records where the start_date
is bigger than now() and here is what I'm trying:
$newStarters = User::has('periods', 1)->with(['periods' => function($q) {
$q->where('start_date', '>', Carbon::now()->subWeek(2)->format('Y-m-d') );
}])->get();
in this case the date filter does not applies.
What is the propper way to do this?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire