PHPackages                             cariuk/repository-pattern-laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. cariuk/repository-pattern-laravel

ActiveLibrary[Database &amp; ORM](/categories/database)

cariuk/repository-pattern-laravel
=================================

A flexible and powerful Laravel package implementing the Repository Pattern with SOLID principles, featuring auto-detection, dependency injection, CRUD operations, filtering, sorting, pagination, and soft deletes support.

3.1.0(1mo ago)02.8k↑66.7%MITPHPPHP &gt;=8.1

Since Dec 11Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/cariuk/repository-pattern-laravel)[ Packagist](https://packagist.org/packages/cariuk/repository-pattern-laravel)[ Docs](https://github.com/cariuk/repository-pattern-laravel)[ RSS](/packages/cariuk-repository-pattern-laravel/feed)WikiDiscussions main Synced today

READMEChangelog (8)Dependencies (4)Versions (17)Used By (0)

Laravel Repository Pattern
==========================

[](#laravel-repository-pattern)

[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)[![PHP Version](https://camo.githubusercontent.com/7535257ca228724c93658bd52583d4e47a9bab02c356abf6e54c1d575f2151e6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312532422d626c75652e737667)](https://www.php.net/)[![Laravel Version](https://camo.githubusercontent.com/3b9125e452af837fdc8533e34282583ec3d3e151a999911ba9cbe66286bd3e5e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31322e302532422d7265642e737667)](https://laravel.com/)

A flexible and powerful Laravel package that implements the Repository Pattern with built-in support for CRUD operations, filtering, sorting, pagination, eager loading, and soft deletes.

Features
--------

[](#features)

- **Clean Architecture**: Separation of concerns with trait-based composition
- **Automatic CRUD**: Pre-built create, read, update, and delete operations
- **Smart Filtering**: Request-driven filtering with custom filter hooks
- **Sorting &amp; Pagination**: Built-in support for sorting and pagination
- **Eager Loading**: Control relationship loading via request parameters
- **Soft Delete Support**: Full support for Laravel's soft deletes with trash management
- **Lifecycle Hooks**: Extensible hooks for custom logic (onCreated, onUpdated, onDeleted, etc.)
- **Transaction Safety**: Automatic database transaction wrapping for write operations
- **Artisan Command**: Generate repositories quickly with `make:repository` command

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- Laravel 12.0 or higher

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require cariuk/laravel-repository-pattern
```

The service provider will be automatically registered.

Quick Start
-----------

[](#quick-start)

### 1. Generate a Repository

[](#1-generate-a-repository)

Use the Artisan command to generate a repository for your model:

```
php artisan make:repository UserRepository User
```

This will create `app/Repositories/UserRepository.php`:

```
