hatchyu/laravel-eloquent-foundation
hatchyu/laravel-eloquent-foundation offers a reusable base layer for Laravel Eloquent models, bundling common traits and helpers that cut boilerplate and keep model behavior consistent across your application.
Architecture fit. The package is a thin, idiomatic Laravel layer: Eloquent traits and query scopes that models opt into via use. That is a low-intrusion pattern — no service provider bootstrapping, no container bindings, no runtime middleware — so it slots into a conventional Laravel monolith or modular monolith without reshaping the domain model. The caveat is that "foundational traits and scopes" is an underspecified value proposition until the actual trait list is read; the package's worth is entirely the quality and semantics of those specific traits (soft-delete behavior, UUID/ULID keys, ordering, active/tenant scopes), not the delivery mechanism.
Integration feasibility. Mechanically trivial: one Composer require, add a trait to a base model or individual models, done. Effort is measured in hours, not sprints. The real work is verification, not integration.
Technical risk. High relative to the code's likely simplicity, and driven by provenance rather than complexity:
hatchyu) that does not match the repository owner (rajeshmk); confirm ownership and publishing rights before trusting the dist artifact.bootTraitName hooks can conflict with an existing base model in non-obvious ways.Key questions.
withoutGlobalScope story for admin, reporting, and data-repair paths?composer.json constraints?Stack fit. Compatible with any standard Laravel 10/11/12 application on PHP 8.1+ using Composer 2. No infrastructure, queue, or database changes. It is a pure code dependency, which also means it is a pure code liability — nothing else in the platform is coupled to it.
Migration path. Recommended posture: treat this as source material, not a dependency.
app/Support/Eloquent/ (or an internal package) with attribution and license compliance. The surface is small enough that this is cheaper than managing an external dependency with a bus factor of one.^0.x or dev-main) in a production application.Compatibility. Before piloting, diff trait method names against the existing base model and any other traits in use, and diff global scope names against existing scopes. Check interaction with soft deletes, multi-tenancy scopes, and any query builder macros already registered. Run the application's existing test suite with the trait applied to one model and compare query logs for unexpected where clauses.
Sequencing.
The abstraction step matters: routing usage through an internal base model means the eventual replace-or-remove decision is a one-file change rather than a codebase-wide refactor.
Maintenance. Bus factor of one, no visible release cadence, no dependents generating bug reports. The mitigating factor is that the code footprint is small and forkable — exit cost is low, so the abandonment risk is bounded. Budget a named internal owner regardless; an unowned third-party trait on a core model is the scenario that produces surprise breakage during a Laravel major upgrade.
Support. No vendor SLA, no commercial backing, community issues only. Internal teams must be prepared to debug Eloquent internals themselves. That is a reasonable ask for a small trait package and an unreasonable one if the team is thin on Laravel depth.
Scaling. Runtime cost is effectively zero — traits are compile-time and scopes are just where clauses. The scaling concern is query-shaped, not throughput-shaped: global scopes add predicates to every query, so confirm the underlying columns are indexed, that pagination counts remain correct, and that cache keys account for scope-modified result sets. Scope stacking across multiple traits can produce over-filtered queries in reporting and export paths that are hard to spot in review.
Failure modes.
Ramp-up. Low for anyone fluent in Laravel — reading a handful of traits is an hour. The non-obvious onboarding cost is tribal knowledge: which models carry which scopes, when to bypass them, and why. That belongs in the team's model conventions doc and code-review checklist, otherwise new engineers will write queries that are quietly wrong.
How can I help you explore Laravel packages today?