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

Eloquent Mutators Laravel Package

awobaz/eloquent-mutators

Add get and set mutators to Eloquent attributes without boilerplate accessor methods. Define reusable mutator classes and attach them to model attributes at runtime, keeping models clean and mutator logic reusable across your Laravel projects.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit. awobaz/eloquent-mutators is a leaf-level utility: a single trait plus a registration mapping that plugs reusable getters/setters into Eloquent's attribute pipeline. It touches no routing, queues, caching, or container bindings, so it neither strengthens nor destabilizes the broader architecture. Its fit is therefore narrow and conditional: it only pays off in applications that already express business logic as Eloquent accessors/mutators and are duplicating that logic across models. In a codebase moving toward explicit value objects, custom casts, or DTOs, it adds a second, competing convention for the same job.

Integration feasibility. Integration cost is genuinely low — composer require, add the trait to a model, declare the mapping, ship. No service provider configuration, no published config, no migrations. A single engineer can validate it against one model in under a day. The real cost is not adoption but reversal: the model layer is the most expensive layer to refactor later, and every model that adopts the convention becomes a small piece of migration debt if the package is abandoned.

Technical risk. Several flags compound:

  • The package describes itself as targeting Laravel 5, which has been end-of-life since 2020. Laravel 9 replaced the classic getFooAttribute convention with Attribute objects and reworked the mutator resolution path; anything that hooks Eloquent's internals is version-fragile.
  • 45 stars and 0 dependents means effectively zero ecosystem validation. No public production users to borrow confidence from.
  • Single-maintainer, single-package ownership creates a bus-factor problem; the recent 2025-10-18 release is a positive maintenance signal but may reflect only a constraint bump rather than active feature work.
  • Mutator interception is behaviorally invasive: it interacts with $casts, $appends, $hidden, dirty tracking, getOriginal(), and JSON serialization. Subtle divergence from native semantics is the most likely defect class.
  • Attribute transformation often implies implicit side effects; if the trait permits dynamic dispatch of declared methods, review its input handling before trusting it with user-influenced data.

Key questions for the maintainer/vendor review:

  1. Exact supported matrix of Laravel and PHP versions — is 9/10/11/12 supported or excluded?
  2. Does it override getAttribute/setAttribute/mutateAttribute, or compose with them?
  3. Precedence when both the package mapping and $casts target the same attribute?
  4. Is there a CI test suite, and does it include serialization and dirty-tracking assertions?
  5. What is the documented upgrade path to Laravel's native Attribute casts?

Integration Approach

Stack fit. Acceptable only for a Laravel 5.5–8.x application that is not planning a framework upgrade inside the planning horizon. For Laravel 9+, the framework's own Attribute casting classes already deliver the package's value proposition — reusable, testable, injectable accessors — which makes adopting a third-party dependency a net negative.

Migration path. If adopted for a legacy codebase, treat it as a bridge, not a destination. Introduce an internal trait or base model that wraps the package so call sites depend on our abstraction rather than Awobaz\Mutator. That wrapper is the seam where the implementation is later swapped to native Attribute casts (Laravel 9+) or to explicit getX()/setX() methods. Budget the removal as part of the framework-upgrade epic rather than as a separate initiative.

Compatibility. Pin the exact version in composer.json, add it to the dependency-review list, and run it through the existing Testbench/PHPUnit matrix. Verify against PHP 8.x explicitly; Laravel 5-era packages frequently declare constraints that mask runtime deprecations.

Sequencing.

  1. Spike on a throwaway branch against one non-critical model; port three existing accessors and diff behavior against native output.
  2. Write conformance tests covering serialization, dirty state, getOriginal, mass assignment, and query-builder behavior on affected columns.
  3. Pilot in one bounded domain module for a sprint; instrument for surprises.
  4. Decision gate: expand, or vendor a trimmed copy of the trait internally (~100 lines) to eliminate the external dependency.
  5. If expanded, record the abstraction seam and the exit criteria in the architecture decision log.

Operational Impact

Maintenance. Code volume is small, so the maintenance burden is not in the dependency's complexity but in its ownership: an unowned, low-visibility package whose breakage will surface as confusing model behavior rather than a clean exception. Assume you may need to fork and vendor it; confirm the MIT license permits that (it does) and that a fork is supportable by the current team.

Support. GitHub issues only, no SLA, one maintainer. No commercial backstop. Escalation path is effectively "read the source," which is feasible here precisely because the surface area is small — a genuine mitigating factor.

Scaling. Runtime overhead is negligible. Organizational scaling is the concern: implicit attribute transformations concentrate hidden behavior in models, which degrades onboarding, hurts static analysis and IDE navigation, and makes cross-team model ownership ambiguous. On a team of five this is tolerable; across multiple squads sharing models it becomes a recurring source of "why is this value different here" bugs.

Failure modes.

  • Silent semantic breakage on a Laravel minor/major upgrade when the mutator resolution path changes — surfaces as wrong data, not a crash.
  • Double transformation when a package mapping and a $casts entry target the same attribute.
  • Stale computed values after save()/refresh() if derived attributes are not recalculated.
  • Serialization leakage of computed attributes into API responses via $appends.
  • Divergence between PHP-side mutated values and database-side filtering: where('full_name', ...) will not match a mutator-composed value, producing subtle query/report inconsistencies.

Ramp-up. Learning the trait itself is a few hours. Learning what the codebase's models actually do is the real cost — weeks, proportional to how many models adopt the convention. Any adoption should be paired with documentation of each registered mapping and a lint/test rule that flags new usages.

Recommendation. Do not adopt for greenfield or Laravel 9+ work; the framework has absorbed this capability. For an existing Laravel 5–8 application with real duplication pain, it is a low-cost, low-blast-radius convenience — adopt behind an internal wrapper, pin the version, and schedule its removal alongside the framework upgrade.

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.
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core