jetcod/eloquent-repository
jetcod/eloquent-repository brings a clean repository pattern to Laravel Eloquent. Organize complex queries into reusable, testable classes, keep models slim, and streamline data access across your app. A practical foundation for cleaner controllers, services, and maintainable Laravel projects.
composer require jetcod/eloquent-repository:^1.7. This release requires PHP 8.1+, Laravel 12 or 13, the Carbon 3 line, and Testbench/migration autoloading as shipped by the package—verify your composer.json platform constraints before pulling it into an existing app.php artisan vendor:publish --tag=...) if the package exposes one, and skim the README for the canonical "extend the base repository" example before writing your own abstractions.UserRepository that extends the package's base class, and replace a couple of Model::where(...)->get() calls in a controller or service with repository methods. This keeps the change surface small and shows you the base class API before you commit to it project-wide.findActiveByEmail, paginateWithRelations) your app actually needs. Fighting the base class is the fastest way to make this package feel heavy.UserRepositoryInterface, implement it with your concrete repository, and bind it in a RepositoryServiceProvider. This is what makes the pattern worth the ceremony: controllers and services depend on the interface, and you can swap the implementation (or a fake) without touching call sites.app()->make() or new repositories manually. This keeps mocking straightforward in feature tests.TestCase can pick up migrations without manual registration — lean on that rather than hand-wiring schema.diffIn* results, and check JSON output of date-cast attributes in your tests.loadMigrationsFrom calls in TestCase.->toSql()/->getBindings() dump inside the repository method, or enable query logging (DB::listen) in a local test, to see what the base class actually emits before you blame Eloquent.all() method is dead weight. Introduce repositories where there's genuine query complexity, reuse, or a real need to swap data sources — otherwise you're adding indirection without payoff.composer.json. With a breaking toolchain jump in 1.7, use ^1.7 deliberately and commit the lockfile so environment drift doesn't silently change Laravel/Carbon versions under you.How can I help you explore Laravel packages today?