Support the ongoing development of Laravel.io →
posted 10 years ago
Database
Last updated 2 years ago.
0

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');
}
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

bweston92 bweston92 Joined 3 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.