PHPackages                             josrom/eloquent-crud-repository - 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. josrom/eloquent-crud-repository

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

josrom/eloquent-crud-repository
===============================

All the basic methods to any Laravel project with Repository pattern

13.0.0(2w ago)02.4kMITPHPPHP ^8.3CI failing

Since Jun 7Pushed 2w ago1 watchersCompare

[ Source](https://github.com/JoseVte/eloquent-crud-repository)[ Packagist](https://packagist.org/packages/josrom/eloquent-crud-repository)[ RSS](/packages/josrom-eloquent-crud-repository/feed)WikiDiscussions master Synced yesterday

READMEChangelog (2)Dependencies (5)Versions (20)Used By (0)

Eloquent CRUD Repository
========================

[](#eloquent-crud-repository)

[![CircleCI](https://camo.githubusercontent.com/5431eaa12d8d451dd6787b94395143f13c28bb6abdc5a46652d3eca6b8b4908f/68747470733a2f2f646c2e636972636c6563692e636f6d2f7374617475732d62616467652f696d672f67682f4a6f73655674652f656c6f7175656e742d637275642d7265706f7369746f72792f747265652f6d61737465722e7376673f7374796c653d737667)](https://dl.circleci.com/status-badge/redirect/gh/JoseVte/eloquent-crud-repository/tree/master)[![Latest Stable Version](https://camo.githubusercontent.com/1a83ecbae3d50cf358febfedcb1f9fbb11163738956e14d4163a4b30614127a6/687474703a2f2f706f7365722e707567782e6f72672f6a6f73726f6d2f656c6f7175656e742d637275642d7265706f7369746f72792f76)](https://packagist.org/packages/josrom/eloquent-crud-repository)[![Total Downloads](https://camo.githubusercontent.com/b54f782b795f34cc0f74f888a859a069e94b00253d733dfa2694ad06273c56a2/687474703a2f2f706f7365722e707567782e6f72672f6a6f73726f6d2f656c6f7175656e742d637275642d7265706f7369746f72792f646f776e6c6f616473)](https://packagist.org/packages/josrom/eloquent-crud-repository)[![License](https://camo.githubusercontent.com/4ac88ed45c20664635a44d5b4c0d41b9b94feb4b086545ab752fff3c8cd06b20/687474703a2f2f706f7365722e707567782e6f72672f6a6f73726f6d2f656c6f7175656e742d637275642d7265706f7369746f72792f6c6963656e7365)](https://packagist.org/packages/josrom/eloquent-crud-repository)

### Introduction

[](#introduction)

EloquentCrudRepository provides a well tested and complete base to create more model repositories using the repository pattern with Eloquent as ORM.

Public methods available
------------------------

[](#public-methods-available)

NameParametersReturnallarray $with = \[\]\\Illuminate\\Database\\Eloquent\\CollectionallWithTrashedarray $with = \[\]\\Illuminate\\Database\\Eloquent\\CollectionallTrashedarray $with = \[\]\\Illuminate\\Database\\Eloquent\\Collectionfindint $id, array $with = \[\]\\Illuminate\\Database\\Eloquent\\ModelfindWithTrashedint $id, array $with = \[\]\\Illuminate\\Database\\Eloquent\\ModelfindTrashedint $id, array $with = \[\]\\Illuminate\\Database\\Eloquent\\ModelfindBystring $field, mixed $value, string $comparison = '=', bool $strict = true, array $with = \[\]\\Illuminate\\Database\\Eloquent\\ModelfindByWithTrashedstring $field, mixed $value, string $comparison = '=', bool $strict = true, array $with = \[\]\\Illuminate\\Database\\Eloquent\\ModelfindByTrashedstring $field, mixed $value, string $comparison = '=', bool $strict = true, array $with = \[\]\\Illuminate\\Database\\Eloquent\\ModelnewModelarray $params = \[\]\\Illuminate\\Database\\Eloquent\\Modelcreatearray $params\\Illuminate\\Database\\Eloquent\\Modelupdateint $id, array $params\\Illuminate\\Database\\Eloquent\\Modeldeleteint $idboolforceDeleteint $idboolrestoreint $idboolpaginate\\Illuminate\\Database\\Eloquent\\Builder $query, int $page = 0, int $limit = 15objectpaginateCollection\\Illuminate\\Database\\Eloquent\\Collection $collection, int $page = 0, int $limit = 15objectpaginationint $page = 0, int $limit = 15objectpaginationWithTrashedint $page = 0, int $limit = 15objectpaginationOnlyTrashedint $page = 0, int $limit = 15objectProtected methods available
---------------------------

[](#protected-methods-available)

NameParametersReturncheckCanShow?\\Illuminate\\Database\\Eloquent\\Model $modelvoidcheckCanCreatearray $paramsvoidcheckCanUpdate\\Illuminate\\Database\\Eloquent\\Model $model, array $newValuesvoidcheckCanDelete\\Illuminate\\Database\\Eloquent\\Model $modelvoidcheckCanRestore\\Illuminate\\Database\\Eloquent\\Model $modelvoidcanShow?\\Illuminate\\Database\\Eloquent\\Model $modelboolcanCreatearray $paramsboolcanUpdate\\Illuminate\\Database\\Eloquent\\Model $model, array $newValuesboolcanDelete\\Illuminate\\Database\\Eloquent\\Model $modelboolcanRestore\\Illuminate\\Database\\Eloquent\\Model $modelboolhasSoftDeletesboolUsage
-----

[](#usage)

### Basic repository

[](#basic-repository)

Extend `CrudRepository` and inject your Eloquent model. Annotate with `@extends CrudRepository` so that IDEs and static analysis tools (PHPStan, Psalm) can infer the concrete model type on every return value:

```
use Eloquent\Crud\Repository\Eloquent\CrudRepository;

/**
 * @extends CrudRepository
 */
class UserRepository extends CrudRepository
{
    public function __construct()
    {
        parent::__construct(new User());
    }
}
```

With that annotation in place, `find()`, `create()`, `update()`, `all()`, etc. all resolve to `User` (or `Collection`) in your IDE instead of the base `Model`.

### Access control

[](#access-control)

Override any `can*` method to restrict access. The corresponding `checkCan*` guard calls it and throws `AccessDeniedException` (HTTP 403) on denial:

```
/**
 * @extends CrudRepository
 */
class PostRepository extends CrudRepository
{
    public function __construct()
    {
        parent::__construct(new Post());
    }

    protected function canUpdate(Model $model, array $newValues): bool
    {
        return Auth::id() === $model->user_id;
    }

    protected function canDelete(Model $model): bool
    {
        return Auth::user()->isAdmin();
    }
}
```

### SoftDeletes

[](#softdeletes)

If your model uses the `SoftDeletes` trait, the `WithTrashed` and `OnlyTrashed` variants are automatically available:

```
/**
 * @extends CrudRepository
 */
class PostRepository extends CrudRepository
{
    public function __construct()
    {
        parent::__construct(new Post()); // Post uses SoftDeletes
    }
}

$repo->allWithTrashed();          // active + soft-deleted
$repo->allTrashed();              // only soft-deleted
$repo->findWithTrashed($id);
$repo->findTrashed($id);
$repo->forceDelete($id);
$repo->restore($id);
```

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

[](#installation)

To get the last version of EloquentCrudRepository, simply require the project using [Composer](https://getcomposer.org/):

```
composer require josrom/eloquent-crud-repository
```

Instead, you may of course manually update your require block and run composer update if you so choose:

```
{
    "require": {
        "josrom/eloquent-crud-repository": "^13.0"
    }
}
```

License
-------

[](#license)

EloquentCrudRepository is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

###  Health Score

56

—

FairBetter than 98% of packages

Maintenance96

Actively maintained with recent releases

Popularity16

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity86

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~261 days

Recently: every ~1 days

Total

12

Last Release

19d ago

Major Versions

11.0.0 → 12.0.02025-03-24

3.0.1 → 4.0.12026-04-21

4.0.1 → 11.0.12026-04-24

11.0.1 → 12.0.12026-04-24

12.0.1 → 13.0.02026-04-24

PHP version history (6 changes)1.0.0PHP ^5.6 || ^7.0

2.0.0PHP ^7.2

3.0.0PHP ^7.4

4.0.0PHP ^7.3|^8.0

12.0.1PHP ^8.2

13.0.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/57b1b8418c0389498a0ac7c0e2f5fe0757502e0d380e1099659d785fb71dd6be?d=identicon)[Josrom](/maintainers/Josrom)

---

Top Contributors

[![JoseVte](https://avatars.githubusercontent.com/u/3540836?v=4)](https://github.com/JoseVte "JoseVte (32 commits)")

---

Tags

laravelormeloquentrepository pattern

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/josrom-eloquent-crud-repository/health.svg)

```
[![Health](https://phpackages.com/badges/josrom-eloquent-crud-repository/health.svg)](https://phpackages.com/packages/josrom-eloquent-crud-repository)
```

###  Alternatives

[torann/laravel-repository

Base repository implementation for Laravel

88497.8k2](/packages/torann-laravel-repository)[sofa/model-locking

Pseudo pessimistic model locking with broadcasted events for Laravel Eloquent ORM.

5048.0k](/packages/sofa-model-locking)[sbarre/eloquent-versioned

Add transparent versioning to Laravel 5.2's Eloquent ORM

301.1k](/packages/sbarre-eloquent-versioned)[chocofamilyme/laravel-tarantool

A Tarantool based Eloquent ORM and Query builder for Laravel

182.3k](/packages/chocofamilyme-laravel-tarantool)[andreagroferreira/laravel-sync-tracker

A Laravel package for tracking entity synchronization status between systems

113.0k](/packages/andreagroferreira-laravel-sync-tracker)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
