In plain English: I have three tables. subscription_type
which has many email_subscription
s which has many email
s.
I'm trying to select all email_subscription
records that have a particular subscription_type
, that also don't have any associated email
records that have a status
of Held
.
The particular bit I am stuck on is only returning email_subscriptions
which have zero emails
(with an additional where clause stacked in there described above).
Using Eloquent, I've been able to get a bit of the way, but I don't have any idea how to select all the records that have a relationship count of zero:
$subscriptionsWithNoCorrespondingHeldEmail = EmailSubscriptions::whereHas('subscriptionType', function($q) {
$q->where('name', 'New Mission');
})-; // What do I chain here to complete my query?
Additionally, is this even possible with Eloquent or will I need to use Fluent syntax instead?