jooservices/laravel-repository

Base repositories with CRUD, filtering, ordering and query-from-request for Laravel

Maintainers

Package info

github.com/jooservices/laravel-repository

pkg:composer/jooservices/laravel-repository

Statistics

Installs: 7

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.1.0 2026-04-08 02:17 UTC

README

codecov CI OpenSSF Scorecard PHP Version License: MIT Packagist Version

The JOOservices Laravel Repository package is a PHP 8.5+ Laravel package for trait-based repository composition, CRUD support, filter and order pipelines, and request-driven query assembly.

Package name: jooservices/laravel-repository

Install

composer require jooservices/laravel-repository

Optionally publish the package config:

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

Quick example

use App\Models\User;
use Jooservices\LaravelRepository\Contracts\RepositoryInterface;
use Jooservices\LaravelRepository\Repositories\EloquentRepository;
use Jooservices\LaravelRepository\Traits\HasCrud;
use Jooservices\LaravelRepository\Traits\HasFilter;
use Jooservices\LaravelRepository\Traits\HasOrder;

final class UserRepository extends EloquentRepository implements RepositoryInterface
{
    use HasCrud;
    use HasFilter;
    use HasOrder;

    public function __construct(User $model)
    {
        parent::__construct($model);
    }
}

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

What is supported today

  • trait-based repository composition through segregated contracts and traits
  • CRUD operations through HasCrud
  • filter chains, collection retrieval, and pagination through HasFilter
  • ordering through HasOrder
  • request-driven query parsing through HasRequestQuery
  • opt-in request-query allowlists and strict mode through HasAllowedRequestQuery
  • request-driven field selection, named request filters, callback micro filters, request-query aliases, aggregate include helpers, and value-normalization rules
  • first-class request operators such as exact, partial, beginsWith, and endsWith
  • opt-in request scopes, scope definitions, relation count clauses, nested relation filters including whereHas and whereDoesntHave variants, derived count or exists includes, additional sum or avg or min or max aggregate includes, and cursor pagination
  • reusable criteria stacks through HasCriteria
  • read terminals such as first, firstOrFail, exists, and count through HasRead
  • chunk, lazy, cursor, and lazyById iteration through HasIteration
  • opt-in cache wrappers through HasCache
  • reusable Filter and Order value objects

Important current boundaries

  • repositories opt into behavior through traits; no feature is globally implied
  • query state is lazily created and reset after terminal filter operations
  • RequestQueryParser supports only the implemented clause families

Documentation

Start with:

AI Support

This repository includes an AI skill pack for agents working in Cursor, Claude Code, VS Code, JetBrains, and Antigravity.

Start with:

The canonical skill source lives in .github/skills/, with adapter layers for each supported AI environment.

Development

composer lint:all
composer test

Contributor workflow details live in:

GitHub Actions and Services

The repository workflow set is designed to include CI, release, PR labeler, semantic PR title, scorecard, and secret-scanning workflows.

The CI baseline covers security checks, linting, tests with coverage artifacts, and optional dependency review. Release is tag-driven through vX.Y.Z tags.

Current external service integrations:

  • Codecov for CI coverage uploads when CODECOV_TOKEN is configured
  • Packagist for release-time package update notifications

Changelog

See CHANGELOG.md for version history.

License

This project is licensed under the MIT License.