brokeyourbike/has-source-model
A lightweight Laravel trait that gives any Eloquent model a polymorphic "source" relationship, letting you track and retrieve the record or model a row originated from with minimal setup.
Architecture fit
brokeyourbike/has-source-model-laravel is a single-purpose Eloquent concern: a HasSourceModel trait (plus supporting contract/config and a published migration) that attaches provenance — a model records which other model it was derived from. Architecturally this is a good fit for Laravel: it composes via trait on existing models, follows standard package conventions (auto-discovered service provider, publishable config and migration), and does not impose a repository layer, base class, or container bindings. It slots in alongside our existing models rather than restructuring them. The v3.0.0 reference feature appears additive to that core concept, but the release notes do not say whether it introduces a new column, a new relation type, or a new resolution strategy — that distinction determines whether this is a config change or a schema change for us.
Integration feasibility
Low-to-moderate effort in principle: composer require, publish the migration/config, add the trait and interface to the target models, backfill existing rows. The blocker is not effort but information: v3.0.0 is a major bump whose only breaking-change description is the word "braking." There is no migration guide, no deprecation notice, no indication of renamed methods, changed column names, changed polymorphic type resolution, or a raised PHP/Laravel floor. We cannot estimate blast radius from the notes; we must read the diff at commit cb25541 and compare composer.json between v2 and v3.
Technical risk
reference added a column, every consuming model's table needs a migration; on large tables that is a locking operation to schedule.Key questions
php and illuminate/* constraints? Which Laravel and PHP versions are dropped?reference feature require a new column or migration, and is it opt-in?Stack fit
Standard Laravel/Composer integration — compatible with our Eloquent-based services assuming our Laravel and PHP versions satisfy v3's constraints (unverified; see key question 3). No framework-level conflict expected; the package does not patch core behavior or override query builders. Confirm it does not collide with any existing trait or global scope named source/reference on the same models.
Migration path
^2.0 in composer.json until the diff is reviewed. Audit for any * or unconstrained requirements that could pull v3 in transitively.composer.json, trait method names, migration stubs, and config keys. Produce a one-page impact note.^3.0 on a branch, run the full test suite, and specifically exercise any model using the trait — including soft deletes, polymorphic sources, and eager loading.Compatibility Verify explicitly against each Laravel version we run; if we are mid-upgrade on the framework, sequence the framework bump first so we do not debug two majors at once. Check the package's PHP floor against our oldest runtime — this is the most common cause of a "breaking" minor-looking major in small Laravel packages.
Sequencing
Framework upgrade → package diff review → POC on one low-risk model → full test pass → backfill (if needed) → wider adoption. If reference is genuinely new capability we want, treat it as a separate, later ticket so the v3 upgrade itself stays a pure compatibility change with a clean rollback point.
Maintenance
Assume we own the upgrade risk. Recommend locking to an exact minor (3.0.*) rather than a floating constraint, vendoring or forking if the package becomes load-bearing, and adding a calendar reminder to re-review upstream before our next Laravel major. Given the changelog quality, treat upstream release notes as unreliable and read commits instead.
Support Community-only: GitHub issues, no SLA, no commercial backing. Acceptable for a thin trait; not acceptable if provenance becomes a compliance or audit dependency. In that case, budget for an internal fork with a named owner.
Scaling
The trait is relation-based, so the operational cost is query shape, not throughput. Watch for N+1 when hydrating collections with source models — enforce eager loading (with('source')) and consider a global scope or lint rule. Ensure the source foreign key and polymorphic type columns are indexed; a provenance column without an index turns a detail page into a table scan at volume.
Failure modes
reference added a column via a non-ALGORITHM=INSTANT path.Ramp-up Low. One trait, one config file, one migration — a mid-level Laravel developer is productive in half a day. The cost is concentrated in the v3 upgrade investigation, not in learning the API. Document the trait's semantics (when to set a source, what null means, deletion behavior) in the team's model conventions, because "where did this record come from" is a question future engineers will ask and the package's own docs are thin.
How can I help you explore Laravel packages today?