tusimo/eloquent-default
A Laravel package that lets Eloquent models declare default attribute values, reducing boilerplate and keeping newly created records consistent without repeating assignments across controllers and services.
Architecture fit
v0.1 is a Laravel/PHP package that adds model-level default values—explicitly called out for MongoDB models—and support for “columns data” when persisting to the database. Architecturally this sits in the Eloquent/model layer, likely as a trait, base model extension, or service provider that augments attribute hydration and save behavior. It fits Laravel applications using MongoDB (e.g., jenssegers/mongodb / mongodb/laravel-mongodb), where schema-less collections make application-side defaults especially valuable. Fit for SQL-backed Eloquent is unproven; the release notes only name Mongo as the motivating case.
Integration feasibility
Feasibility is moderate but unverified. The package is pre-1.0, the release notes are two lines, and there is no prior assessment or compatibility matrix. A proof of concept is required before committing to a design: install via Composer, confirm service provider/trait registration, define defaults and columns on a representative model, and verify both create and update paths. The “columns data” feature needs clarification—whether it constrains mass assignment, drives schema-aware saves, or simply passes a column list to the query builder.
Technical risk
Risk is high for production use at v0.1. Specific concerns: unstable public API and likely breaking changes before 1.0; tight coupling to a particular MongoDB driver version; ambiguous semantics between model defaults and database defaults; potential conflict with existing casts, accessors, $fillable, validation, and migration tooling; and sparse documentation that makes failure modes hard to predict. Default-value logic in the application layer can also mask missing data or diverge from database-level defaults, creating inconsistency across services.
Key questions
$attributes, casts, and dirty tracking?Stack fit
Best fit is a Laravel service already using MongoDB via an Eloquent-compatible driver. For SQL-only stacks, the value is limited until SQL support is demonstrated. Align integration with the existing base model or repository layer rather than editing models ad hoc, so defaults and column rules remain centralized.
Migration path
There is no prior assessment, so treat this as a greenfield, sidecar integration. Start in a non-critical service or internal tool. Pin the exact v0.1.x version in composer.json and avoid floating constraints. Wrap the package behind a thin adapter or base model so it can be replaced if the package stalls or introduces breaking changes.
Compatibility
Build a small compatibility matrix before rollout: Laravel version, PHP version, Mongo extension/driver version, and the specific Mongo Eloquent package version. Test default resolution on create vs. update, nested/embedded documents, and bulk inserts. Verify that “columns data” does not silently drop attributes or bypass validation.
Sequencing
Maintenance
Pre-1.0 packages carry ongoing upgrade cost. Expect breaking changes and require an internal owner to track releases, pin versions, and review diffs. Without a prior assessment, there is no baseline for regression detection; establish one now.
Support
Documentation appears minimal, and community support is unknown. Budget for internal documentation and a fallback implementation. Confirm license terms and whether security issues have a disclosure path.
Scaling
Runtime overhead is likely low—defaults are typically resolved in-process before persistence. Watch for per-save computation on large batches and any default logic that triggers additional queries. For high-volume Mongo writes, validate that column shaping does not force per-document round trips.
Failure modes
Ramp-up
The code surface is likely small, but uncertainty is high. Allocate a short spike with a Mongo-experienced engineer, pair on the first integration, and treat v0.1 as experimental until a stable release, test coverage, and version compatibility are confirmed.
How can I help you explore Laravel packages today?