You want to retrieve mortgages
not products
and event to check is MORTGAGE, CONTACTED, right?
Mortgage::whereHas('case', function($q) {
$q->whereHas('events', function($q){
$q->where('type', '=', 'CONTACTED'); // or better check for event id here, up to you
}, '<', 1); // -> not having that event
})->get();
// as long as you have the relations:
// Case model
public function events()
{
return $this->belongsToMany('Event', 'cases_timeline')
}
// Mortgage model
public function case()
{
return $this->belongsTo('Case');
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community