Weave 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 When On Relation Laravel Package

mashirou1234/laravel-when-on-relation

Adds a whenOnRelation helper to Laravel Eloquent so you can run callbacks or apply constraints only when a relationship is loaded or present. It keeps relation-aware models, queries, and API resources concise and free of repetitive checks.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • API/resource shaping: whenOnRelation() lets teams apply constraints or eager-loading behavior conditionally on an Eloquent relation instance, reducing one-off branching in controllers, resources, and query scopes.
  • Feature-flag and role-based data exposure: Relation-specific callbacks can keep conditional relation logic closer to the model/relationship definition instead of scattering if statements across request handlers.
  • Build vs. buy: The helper is small and opt-in, so adoption is a low-cost convenience decision rather than a platform commitment. It is best treated as a tactical DX improvement, not a strategic dependency.
  • Roadmap fit: Useful where products expose configurable nested resources, tenant-specific relationship constraints, or conditional includes. It does not replace broader query-builder abstractions or authorization layers.
  • Standardization: If multiple teams repeatedly write ad hoc conditional relation logic, this helper can become a small internal convention. At v0.1.0, treat it as an experiment pending production validation.

When to Consider This Package

Consider adoption when:

  • Your codebase already uses Eloquent relationships heavily and has repeated conditional relation-constraint patterns.
  • You want an opt-in helper that explicitly preserves Laravel’s existing when() behavior and avoids changing native query semantics.
  • You can pin the dependency at 0.1.x, review the implementation, and accept early-stage API stability risk.
  • The team values small, composable helpers over introducing a larger query/filtering package.

Look elsewhere or defer when:

  • Native when() on queries or ordinary relationship constraints already cover your use cases.
  • You need mature documentation, long-term support guarantees, or a broad feature set; v0.1.0 indicates an initial, narrow release.
  • The package is unmaintained, lacks tests, or its abstraction would hide important query behavior from the team.
  • Your architecture depends on complex filtering, authorization-aware includes, or GraphQL-style relation selection that requires a more complete solution.

How to Pitch It (Stakeholders)

For executives: This is a small, low-risk Laravel convenience package that reduces repeated conditional relationship logic in application code. It is opt-in and does not alter Laravel’s default behavior, so adoption can be scoped to a pilot without platform-wide change.

For engineering: v0.1.0 adds whenOnRelation() for Eloquent relationship instances while keeping Laravel’s existing when() unchanged. It is useful for cleaning up conditional relation callbacks, but it is early-stage and narrow in scope. Recommend pinning the version, reviewing test coverage/maintenance, and piloting in one service before standardizing. Do not position it as a replacement for query filters, authorization, or API resource layers.

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.
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console