Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Morph Where Has Laravel Package

rackbeat/laravel-morph-where-has

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Enabling polymorphic query flexibility: Allows teams to use 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").
  • Roadmap for query-driven features: Justifies investing in polymorphic relationships without sacrificing Eloquent’s query builder power. Example: A billing system where invoices can belong to Users, Companies, or Partners—now queryable via whereHas('customer').
  • Build vs. buy: Avoids custom SQL or raw query workarounds, reducing technical debt. The package’s MIT license and minimalism make it a low-risk "buy."
  • Use cases:
    • Multi-tenant systems: Filter records by polymorphic tenant types (e.g., whereHas('tenant')->where('active', true)).
    • Audit trails: Query logs where the user is a SuperAdmin or RegularUser.
    • Marketplaces: Filter listings by polymorphic seller types (e.g., whereHas('seller')->where('verified', true)).

When to Consider This Package

  • Adopt if:
    • Your Laravel app uses polymorphic relationships (morphTo, morphMany) but lacks whereHas support for them.
    • You need clean, maintainable queries instead of raw SQL or complex joins.
    • Your team prioritizes developer velocity over custom solutions (installation is trivial).
    • The package’s opportunity score (23.57) aligns with your need for niche but impactful fixes (e.g., e-commerce, SaaS platforms).
  • Look elsewhere if:
    • You’re using non-Laravel PHP or a framework without Eloquent.
    • Your polymorphic queries are already handled via custom accessors/mutators or scopes.
    • The package’s last release (2022) is a concern for long-term maintenance (though MIT license mitigates this).
    • You need advanced morph features (e.g., dynamic morph maps) beyond whereHas—consider extending this package or alternatives like staudenmeir/eloquent-eager-limit.

How to Pitch It (Stakeholders)

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."*

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver