jooservices/laravel-repository

PHP 8.5+ Laravel repository package for trait-based CRUD, filtering, ordering, and request-driven query composition
2,256
Install
composer require jooservices/laravel-repository
Latest Version:v4.0.0
PHP:>=8.5
License:MIT
Last Updated:Oct 1, 2026
Links: GitHub  ·  Packagist
Maintainer: jooservices

jooservices/laravel-repository

CI Coverage (develop) OpenSSF Scorecard PHP Version GitHub Release Packagist Version Total Downloads License: MIT

jooservices/laravel-repository is a PHP ^8.5 Laravel package for composing Eloquent repositories from opt-in traits, with CRUD, filtering, ordering, and request-driven query capabilities.

Upgrade note: The current release line is v4.0.0. Review UPGRADE-4.0.md before upgrading from 1.x; the major release includes API and behavior changes.

Features

  • Compose repository capabilities with traits and segregated contracts.
  • Use the ApiRepository and ReadRepository presets or generate a repository with Artisan.
  • Add CRUD, filters, ordering, criteria, soft deletes, locking, cache wrappers, and cursor pagination as needed.
  • Build request-driven queries with allowlists, strict mode, named filters, field selection, scopes, relation filters, aggregate includes, and query profiles.
  • Reuse Filter and Order value objects.

Requirements

  • PHP ^8.5
  • Laravel 12 or 13
  • Composer

Installation

composer require jooservices/laravel-repository:^4.0

Laravel package discovery registers the service provider. To publish the optional config or repository stubs:

php artisan vendor:publish --tag=laravel-repository-config
php artisan vendor:publish --tag=laravel-repository-stubs

Quick start

Extend the API preset for a repository with CRUD, filtering, ordering, reads, and request-query support:

use App\Models\User;
use JOOservices\LaravelRepository\Repositories\Presets\ApiRepository;

/** @extends ApiRepository<User> */
final class UserRepository extends ApiRepository
{
    public function __construct(User $model)
    {
        parent::__construct($model);
    }
}

$repository = app(UserRepository::class);
$user = $repository->find($id);
$users = $repository
    ->filter(['status' => 'active'])
    ->orderBy(['-created_at'])
    ->paginate(15);

Or scaffold a repository with the api preset:

php artisan make:repository UserRepository --model=User --preset=api

Design notes

  • Capabilities are opt-in; the package does not apply repository behavior globally.
  • Fluent query state is lazy and resets after terminal operations such as get() and paginate().
  • Request-query clauses and relation discovery follow the supported rules in Request Query Support.

Documentation

Development

Install dependencies and run the configured quality commands:

composer install
composer lint
composer test
composer check
composer ci

See contributor guidance, development setup, coding standards, testing, and CI/CD.

Community

License

This project is licensed under the MIT License.

Related Packages

jooservices/laravel-config

MongoDB-backed application configuration store for Laravel with typed access and...

1,397 0
cariuk/repository-pattern-laravel

A flexible and powerful Laravel package implementing the Repository Pattern with...

2,960 0
dev-toolbelt/laravel-fast-crud

Laravel package for rapid CRUD API scaffolding with filtering, sorting, paginati...

1,800 3
kajalpandya/generate_laravel_crud

Run command in terminal and make ready made crud for your entity

1,474 14
cariuk/laravel-repository-pattern

A flexible and powerful Laravel package implementing the Repository Pattern with...

1,033 0

Version History

Version Released PHP Laravel License
v4.0.0 >=8.5 ^12.0|^13.0 MIT