$jobs = EventJob::with(['applications' => function ($query) {
$query->where('accepted', false);
}, 'job' => function($query) {
$query->where('division_id', 1);
}, 'event' => function($query) use ($date) {
$query->where('date', '>=', $date);
}])->get();
Complete overhaul of the question.
I wan't only the EventJob elements where the conditions in the $query are true but I get all the elements.
Seems like the function you're looking for is whereHas
, it is documented here.
Your code would then be :
$jobs = EventJob::whereHas('applications', function ($query) {
$query->where('accepted', false);
})->whereHas('job', function($query) {
$query->where('division_id', 1);
})->wherehas('event', function($query) use ($date) {
$query->where('date', '>=', $date);
})->get();