PHPackages                             nathanbarrett/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. nathanbarrett/laravel-repositories

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

nathanbarrett/laravel-repositories
==================================

Repository service layer for Laravel apps

v1.2.0(1y ago)0146MITPHPPHP ^8.2CI failing

Since Apr 20Pushed 1y ago1 watchersCompare

[ Source](https://github.com/nathanbarrett/laravel-repositories)[ Packagist](https://packagist.org/packages/nathanbarrett/laravel-repositories)[ Docs](https://github.com/nathanbarrett/laravel-repositories)[ GitHub Sponsors]()[ RSS](/packages/nathanbarrett-laravel-repositories/feed)WikiDiscussions main Synced today

READMEChangelog (4)Dependencies (12)Versions (6)Used By (0)

Repository service layer for Laravel apps
=========================================

[](#repository-service-layer-for-laravel-apps)

[![Latest Version on Packagist](https://camo.githubusercontent.com/1d9f7da648070552b0d660ab2f3992fe5b716befd0508ddaa4b4080662bd76a8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e617468616e626172726574742f6c61726176656c2d7265706f7369746f726965732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/nathanbarrett/laravel-repositories)[![GitHub Tests Action Status](https://camo.githubusercontent.com/732be7dc7aa9787d404579757535b15a42df8b5dbbdee1faab89596c70c2c3f0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6e617468616e626172726574742f6c61726176656c2d7265706f7369746f726965732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/nathanbarrett/laravel-repositories/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/a9dab4968994f06544d4f201ed9291ed26bfff6023daf3de8da75bcf48659d0c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6e617468616e626172726574742f6c61726176656c2d7265706f7369746f726965732f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/nathanbarrett/laravel-repositories/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/a2aadf0405202c9d8b7353cab82ed8687d803c9d1e0daf81e43804f98c55231f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e617468616e626172726574742f6c61726176656c2d7265706f7369746f726965732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/nathanbarrett/laravel-repositories)

Repositories are meant to act as a middle layer between Models and higher level objectives like services. They are meant to abstract the data layer and provide a clean API for data access. Use a repository when the action is mostly or entirely about the related model.

#### Layers of a Laravel application using Repositories

[](#layers-of-a-laravel-application-using-repositories)

- **Service** - Highest level of abstraction. Uses Repositories and Models to perform actions. Example: `StripePaymentService`
- **Repository** - Middle layer of abstraction. Uses Models (not just the related Model) to perform actions. Example: `UserRepository`
- **Model** - Lowest level of abstraction. Represents a single table in the database. Use only for relations and light transforms of the data. Example: `User`

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

[](#installation)

You can install the package via composer:

```
composer require nathanbarrett/laravel-repositories
```

Usage
-----

[](#usage)

First create a repository class

```
use NathanBarrett\LaravelRepositories\Repository;
use App\Models\User;

/**
* @extends Repository
 */
class UserRepository extends Repository
{
    public function modelClass(): string
    {
        return User::class;
    }
}
```

Generics are used to ensure that your IDE can provide code completion and type hinting.

```
class UserController extends Controller
{
    public function __construct(private UserRepository $userRepository)
    {
       //
    }

    public function store(Request $request)
    {
        // The IDE will understand that $user is an instance of User
        $user = $this->userRepository->create($request->all());
        return response()->json($user);
    }
}
```

Or you can quickly create one using the command

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

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

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

License
-------

[](#license)

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

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance42

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 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 ~114 days

Total

4

Last Release

461d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7461430?v=4)[Nathan Barrett](/maintainers/nathanbarrett)[@nathanbarrett](https://github.com/nathanbarrett)

---

Top Contributors

[![nathanbarrett](https://avatars.githubusercontent.com/u/7461430?v=4)](https://github.com/nathanbarrett "nathanbarrett (8 commits)")

---

Tags

laravellaravel-repositoriesNathan Barrett

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[codewithdennis/filament-select-tree

The multi-level select field enables you to make single selections from a predefined list of options that are organized into multiple levels or depths.

329530.5k29](/packages/codewithdennis-filament-select-tree)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

124603.0k](/packages/worksome-exchange)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)[tarfin-labs/event-machine

Event-driven state machines for Laravel with event sourcing, type-safe context, and full audit trail.

199.4k](/packages/tarfin-labs-event-machine)[tapp/filament-form-builder

User facing form builder using Filament components

132.4k3](/packages/tapp-filament-form-builder)

PHPackages © 2026

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