Good morning.
I have a question that I can't solve with eloquent, let me put it in context.
I have several farms I need all the subscribers of that farm that are taken out through a pivot table and in turn all the receipts of those subscribers, so far so good. The problem comes in that I put a condition in the dates of the receipts, and I want that it does not extract the subscribers that do not fulfill that condition.
$estates = Estate::with(['adminEstate.neighbours' => function ($query) use ($past_date_init) {
$query->with(['receiptHeader' => function ($query2) use ($past_date_init) {
$query2
->where('receipt_h_billing_init', '<=', $past_date_init)
->where('receipt_h_billing_end', '>=', $past_date_init);
$query2->with('receiptDetail');
}
]);
}])->get();
If they do not meet the date condition, I will not be able to get the subscribers.
Thanks for your help