PHPackages                             nalingia/laravel-repositories - 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. nalingia/laravel-repositories

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

nalingia/laravel-repositories
=============================

A Laravel package for the Repository Design Pattern.

1.5.0(6y ago)114.2k1MITPHPPHP ^7.2

Since Jan 9Pushed 6y ago1 watchersCompare

[ Source](https://github.com/nalingia/laravel-repositories)[ Packagist](https://packagist.org/packages/nalingia/laravel-repositories)[ RSS](/packages/nalingia-laravel-repositories/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (1)Dependencies (5)Versions (16)Used By (0)

A Laravel package for the Repository design pattern
===================================================

[](#a-laravel-package-for-the-repository-design-pattern)

[![Latest Version on Packagist](https://camo.githubusercontent.com/37a8c35cea22ce2f0ca1a937801e8cb7b3a84cafdb37a48ce8a2ef2a227b6e9d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e616c696e6769612f6c61726176656c2d7265706f7369746f726965732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/nalingia/laravel-repositories)[![Build Status](https://camo.githubusercontent.com/36ecc80c580d339c7f2bddaf80e83a0f41f1ffb0c2c14c042952d849dcbd95d1/68747470733a2f2f7472617669732d63692e6f72672f6e616c696e6769612f6c61726176656c2d7265706f7369746f726965732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/nalingia/laravel-repositories)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/57b4d3fd88d29c2f1f42381ac0f3f958c21b8b425e96e0e789becc0c5c60219c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e616c696e6769612f6c61726176656c2d7265706f7369746f726965732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/nalingia/laravel-repositories)

Repositories is a simple package to simplify the creation of scaffolding code when using the [Repository Design Pattern](https://msdn.microsoft.com/en-us/library/ff649690.aspx). It adds an artisan command which creates the repository and the related contract.

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

[](#installation)

You can install the package via composer:

```
composer require nalingia/laravel-repositories
```

Then you have to add the related Service Provider to the `providers` configuration array in `config/app.php`:

```
'providers' => [
  ...
  Nalingia\Repositories\RepositoriesServiceProvider::class,
  ...
]
```

Usage
-----

[](#usage)

The package provides an additional artisan command called `make:repository` which accepts as only parameter the model's class name.

For instance, if you need to create a repository of users you can type:

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

The command will create both the repository and the related contract in `app/Repositories` and `app/Repositories/Contracts` folders, respectively. Default folders and namespaces can be changed

### Available API

[](#available-api)

The generated repositories will inherit from `Nalingia\Repositories\AbstractEloquentRepository` which provides a bunch of useful and general purpose methods:

- Get all models:

```
public function all(array $with = []);
```

- Get model having the given id:

```
public function findById($id, array $with = [], $fail = true);
```

- Get the first model having `$key` attribute equals to `$value`:

```
public function getFirstBy($key, $value, array $with = [], $comparator = '=', $fail = false);
```

- Get all models having `$key` attribute equals to `$value`:

```
public function getManyBy($key, $value, array $with = [], $comparator = '=');
```

- Get first model matching `$where` clauses:

```
public function getFirstWhere(array $where, $with = [], $fail = false);
```

- Get all models matching `$where` clauses:

```
public function getAllWhere($where, $with = [], $columns = ['*']);
```

- Get paginated models:

```
public function getByPage($page = 1, $limit = 10, array $with = []);
```

- Create a new model:

```
public function create(array $data);
```

- Update a model:

```
public function update($model, array $data);
```

- Delete a model:

```
public function delete($model);
```

- Truncate the table related to the model:

```
public function truncate();
```

- Get all models having `column_name` in `$needles`:

```
public function getAllWhereColumnNameIn(array $needles, array $with = []);
```

You can contribute to the common methods by proposing a pull request.

### Settings

[](#settings)

If you need to change the default command settings, you can publish the `repositories.php` configuration file using the command:

```
php artisan vendor:publish --provider="Nalingia\Repositories\RepositoriesServiceProvider"
```

Change log
----------

[](#change-log)

Please, see [CHANGELOG](CHANGELOG.md) for more information about what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Testing
-------

[](#testing)

You can run the tests with:

```
composer test
```

or

```
vendor/bin/phpunit
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 97.8% 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 ~51 days

Recently: every ~136 days

Total

13

Last Release

2485d ago

PHP version history (3 changes)1.0.0PHP ^7.0

1.3.2PHP ^7.1

1.4.0PHP ^7.2

### Community

Maintainers

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

---

Top Contributors

[![nalingia](https://avatars.githubusercontent.com/u/5793125?v=4)](https://github.com/nalingia "nalingia (45 commits)")[![gnalin-hfarm](https://avatars.githubusercontent.com/u/28861832?v=4)](https://github.com/gnalin-hfarm "gnalin-hfarm (1 commits)")

---

Tags

ormmodelrepositoriesdesign pattern

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nalingia-laravel-repositories/health.svg)

```
[![Health](https://phpackages.com/badges/nalingia-laravel-repositories/health.svg)](https://phpackages.com/packages/nalingia-laravel-repositories)
```

###  Alternatives

[illuminate/database

The Illuminate Database package.

2.8k54.1M11.2k](/packages/illuminate-database)[prettus/l5-repository

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

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

The official AI SDK for Laravel.

1.0k2.1M169](/packages/laravel-ai)[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k5.0M31](/packages/tucker-eric-eloquentfilter)[moonshine/moonshine

Laravel administration panel

1.3k239.9k76](/packages/moonshine-moonshine)[erag/laravel-lang-sync-inertia

A powerful Laravel package for syncing and managing language translations across backend and Inertia.js (Vue/React) frontends, offering effortless localization, auto-sync features, and smooth multi-language support for modern Laravel applications.

4821.5k](/packages/erag-laravel-lang-sync-inertia)

PHPackages © 2026

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