jooservices/laravel-repository

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

jooservices/laravel-repository

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

JOOservices Laravel Repository is a PHP 8.5+ Laravel package for trait-based repository composition: CRUD, filtering, ordering, criteria, and request-driven query composition on Eloquent.

Composer package: jooservices/laravel-repository — current line: v4.0.0. Upgrading from 1.x: see UPGRADE-4.0.md.

Install

composer require jooservices/laravel-repository:^4.0

Optionally publish config and stubs:

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

Quick example

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);

Scaffold:

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

See the Cookbook for profiles, value rules, soft deletes, locking, and debug helpers.

What is supported today

  • trait-based composition through segregated contracts and traits
  • presets ApiRepository / ReadRepository and Artisan make:repository
  • CRUD (HasCrud) including findMany, findBy, updateOrCreate, upsert
  • filters, pagination, and simplePaginate (HasFilter)
  • ordering and sort shorthand (HasOrder)
  • request-driven queries (HasRequestQuery) with allowlists / strict mode
  • named filters, field selection, scopes, relation filters, aggregate includes
  • operators including exact, partial, before, after, date, jsonContains
  • criteria (HasCriteria), soft deletes, locking, SQL debug
  • named query profiles with restrictive baseline semantics
  • cursor pagination that preserves sparse and Expression projections
  • opt-in cache wrappers (HasCache) with stable typed cache keys
  • reusable Filter and Order value objects

Important boundaries

  • capabilities are opt-in through traits; nothing is globally implied
  • query state is lazy and resets after terminal operations
  • RequestQueryParser supports only the documented clause families
  • relation methods should declare a Relation return type (or use an explicit trust / allowlist path)

Documentation

Development

composer lint
composer test
composer check

Contributor workflow:

Project agents: AGENTS.md (workspace policy in the JOOservices root AGENTS.md).

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
kajalpandya/generate_laravel_crud

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

1,474 14
riesjart/eloqrud

Eloquent CRUD through repositories

688 0
okaybueno/laravel-repositories

A package that provides a neat implementation to integrate the Repository patter...

16,100 18
cariuk/repository-pattern-laravel

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

2,933 0