rackbeat/laravel-morph-where-has
whereHas() on polymorphic relationships (e.g., morphTo), unlocking complex filtering for models like Invoice (e.g., "find invoices where the owner is an active Customer").Users, Companies, or Partners—now queryable via whereHas('customer').whereHas('tenant')->where('active', true)).user is a SuperAdmin or RegularUser.whereHas('seller')->where('verified', true)).morphTo, morphMany) but lacks whereHas support for them.whereHas—consider extending this package or alternatives like staudenmeir/eloquent-eager-limit.For Executives:
"This package lets us query polymorphic relationships (like invoices owned by different user types) using Laravel’s built-in whereHas(), saving dev time and reducing bugs. For example, we could finally filter ‘active customer invoices’ without custom SQL. It’s a 10-minute install with a 10x query improvement—low risk, high reward for features like multi-tenancy or marketplaces."
For Engineering:
*"The package fixes a gap in Laravel’s Eloquent: whereHas() doesn’t work out-of-the-box for morphTo relations. By adding a forClass() constraint to our polymorphic models (e.g., customer() for Invoice), we unlock reusable queries like:
Invoice::whereHas('customer')->where('customers.active', true);
No more raw SQL or hacky joins. The MIT license and minimal footprint make it a no-brainer for teams using polymorphic relationships."*
How can I help you explore Laravel packages today?