PHPackages                             m2quared/eloquent-depot - 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. m2quared/eloquent-depot

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

m2quared/eloquent-depot
=======================

Repositories to the database layer

v5.0.0(5y ago)120.1kMITPHPCI failing

Since May 19Pushed 5y ago3 watchersCompare

[ Source](https://github.com/m2quared/Eloquent-Depot)[ Packagist](https://packagist.org/packages/m2quared/eloquent-depot)[ RSS](/packages/m2quared-eloquent-depot/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (10)Dependencies (7)Versions (13)Used By (0)

Eloquent Depot
==============

[](#eloquent-depot)

Eloquent Depot is used to abstract the data layer, making our application more flexible to maintain.

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
    - [Composer](#composer)
    - [Laravel](#laravel)

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

[](#installation)

### Composer

[](#composer)

Execute the following command to get the latest version of the package:

```
composer require m2quared/l5-repository

```

### Laravel

[](#laravel)

In your `config/app.php` add `M2quared\Repository\Providers\RepositoryServiceProvider::class` to the end of the `providers` array:

```
'providers' => [
    ...
    M2quared\Repository\Providers\RepositoryServiceProvider::class,
],
```

If Lumen

```
$app->register(M2quared\Repository\Providers\LumenRepositoryServiceProvider::class);
```

Publish Configuration

```
php artisan vendor:publish
```

Methods
-------

[](#methods)

### M2quared\\Repository\\Contracts\\RepositoryInterface

[](#m2quaredrepositorycontractsrepositoryinterface)

- all($columns = array('\*'))
- first($columns = array('\*'))
- paginate($limit = null, $columns = \['\*'\])
- find($id, $columns = \['\*'\])
- findByField($field, $value, $columns = \['\*'\])
- findWhere(array $where, $columns = \['\*'\])
- findWhereIn($field, array $where, $columns = \[\*\])
- findWhereNotIn($field, array $where, $columns = \[\*\])
- create(array $attributes)
- update(array $attributes, $id)
- updateOrCreate(array $attributes, array $values = \[\])
- delete($id)
- orderBy($column, $direction = 'asc');
- with(array|string $relations);
- withCount(array|string $relations)
- limit($value)
- hidden(array $fields);
- visible(array $fields);
- scopeQuery(Closure $scope);
- getFieldsSearchable();
- setPresenter($presenter);
- skipPresenter($status = true);

Usage
-----

[](#usage)

### Create a Model

[](#create-a-model)

Create your model normally, but it is important to define the attributes that can be filled from the input form data.

```
namespace App;

class Post extends Eloquent { // or Ardent, Or any other Model Class

    protected $fillable = [
        'title',
        'author',
        ...
     ];

     ...
}
```

### Create a Repository

[](#create-a-repository)

```
namespace App;

use M2quared\Repository\Eloquent\BaseRepository;

class PostRepository extends BaseRepository {

    /**
     * Specify Model class name
     *
     * @return string
     */
    function model()
    {
        return "App\\Post";
    }
}
```

### Use methods

[](#use-methods)

```
namespace App\Http\Controllers;

use App\PostRepository;

class PostsController extends BaseController {

    /**
     * @var PostRepository
     */
    protected $repository;

    public function __construct(PostRepository $repository){
        $this->repository = $repository;
    }

    ....
}
```

Find all results in Repository

```
$posts = $this->repository->all();
```

Find all results in Repository with pagination

```
$posts = $this->repository->paginate($limit = null, $columns = ['*']);
```

Find by result by id

```
$post = $this->repository->find($id);
```

Hiding attributes of the model

```
$post = $this->repository->hidden(['country_id'])->find($id);
```

Showing only specific attributes of the model

```
$post = $this->repository->visible(['id', 'state_id'])->find($id);
```

Loading the Model relationships

```
$post = $this->repository->with(['state'])->find($id);
```

Find by result by field name

```
$posts = $this->repository->findByField('country_id','15');
```

Find by result by multiple fields

```
$posts = $this->repository->findWhere([
    //Default Condition =
    'state_id'=>'10',
    'country_id'=>'15',
    //Custom Condition
    ['columnName','>','10']
]);
```

Find by result by multiple values in one field

```
$posts = $this->repository->findWhereIn('id', [1,2,3,4,5]);
```

Find by result by excluding multiple values in one field

```
$posts = $this->repository->findWhereNotIn('id', [6,7,8,9,10]);
```

Find all using custom scope

```
$posts = $this->repository->scopeQuery(function($query){
    return $query->orderBy('sort_order','asc');
})->all();
```

Create new entry in Repository

```
$post = $this->repository->create( Input::all() );
```

Update entry in Repository

```
$post = $this->repository->update( Input::all(), $id );
```

Delete entry in Repository

```
$this->repository->delete($id)
```

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 50% 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 ~148 days

Recently: every ~166 days

Total

12

Last Release

2066d ago

Major Versions

v1.0.1 → v2.0.02017-06-01

v2.1.3 → v3.0.02019-01-08

v3.1.1 → v4.0.02020-07-02

v4.0.0 → v5.0.02020-11-02

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/340752?v=4)[Mark Beech](/maintainers/JayBizzle)[@JayBizzle](https://github.com/JayBizzle)

![](https://www.gravatar.com/avatar/e99b303a1f20ee3bbd58a15db61aaf685afccab6c76dcd8c5be7b15b05b8d219?d=identicon)[MaxGiting](/maintainers/MaxGiting)

---

Top Contributors

[![GC-Mark](https://avatars.githubusercontent.com/u/1477806?v=4)](https://github.com/GC-Mark "GC-Mark (28 commits)")[![JayBizzle](https://avatars.githubusercontent.com/u/340752?v=4)](https://github.com/JayBizzle "JayBizzle (22 commits)")[![GC-Max](https://avatars.githubusercontent.com/u/10233281?v=4)](https://github.com/GC-Max "GC-Max (5 commits)")[![MaxGiting](https://avatars.githubusercontent.com/u/9828591?v=4)](https://github.com/MaxGiting "MaxGiting (1 commits)")

---

Tags

laravelmodeleloquentcacherepository

### Embed Badge

![Health badge](/badges/m2quared-eloquent-depot/health.svg)

```
[![Health](https://phpackages.com/badges/m2quared-eloquent-depot/health.svg)](https://phpackages.com/packages/m2quared-eloquent-depot)
```

###  Alternatives

[prettus/l5-repository

Laravel 8|9|10|11|12|13 - Repositories to the database layer

4.2k11.2M155](/packages/prettus-l5-repository)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9772.3M122](/packages/roots-acorn)[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k5.0M31](/packages/tucker-eric-eloquentfilter)[api-platform/laravel

API Platform support for Laravel

59156.3k11](/packages/api-platform-laravel)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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