Reputation: 3
I have two tables students
and exams
. I want to get the students who have exams as last exam date was before one year from today.
How I can do this query with Laravel eloquent?
Upvotes: 0
Views: 30
Reputation: 3869
$students = $students->whereDoesntHave( 'exams', function ( $query ) {
$query->where( 'created_at', '>', Carbon::now()->startOfYear() );
} )
This should query students who don't have exams created after the first day of the current year. I don't know if this is this date query that you want, but you get the idea.
Assuming:
Upvotes: 1