Level 102
Please show the relationship definitions
But something like this I would assume
$event->invoices->where('paid', false)->where('billable_id', $student->id)
->where('invoicable_type', 'App\User')->get();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have a students page with where each student has an invoice for the course, and i want to check the status of each invoice (paid/unpaid) for each student.
$event->invoices->where('paid', false)->where('billable_id', $student->id)
That retrieves it fine, but this is a polymorphic relationship so sometimes the billable_id might reference another model. How can I search through only users.
Point me in the right direction! Thanks
Please show the relationship definitions
But something like this I would assume
$event->invoices->where('paid', false)->where('billable_id', $student->id)
->where('invoicable_type', 'App\User')->get();
Please or to participate in this conversation.