PHPackages                             lerouse/laravel-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. lerouse/laravel-repository

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

lerouse/laravel-repository
==========================

Repository implementation for Laravel.

v2.7.0(7mo ago)513.8k↓20%34MITPHPPHP ^8.1|^8.2|^8.3|^8.4

Since Oct 6Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/lerouse/laravel-repository)[ Packagist](https://packagist.org/packages/lerouse/laravel-repository)[ RSS](/packages/lerouse-laravel-repository/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (8)Versions (14)Used By (4)

Laravel Model Repository
========================

[](#laravel-model-repository)

[![Laravel Repository Build](https://github.com/lerouse/laravel-repository/actions/workflows/laravel-repository-build-test.yml/badge.svg)](https://github.com/lerouse/laravel-repository/actions/workflows/laravel-repository-build-test.yml)[![Latest Stable Version](https://camo.githubusercontent.com/b608888256195b36941888faea7503f3f65b8d62e80bbfecf8b30919ac733ab9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c65726f7573652f6c61726176656c2d7265706f7369746f7279)](https://packagist.org/packages/lerouse/laravel-repository)[![License](https://camo.githubusercontent.com/97db79bd1acd6095a3d6a41135b41fb6a2c69f7ccccb50aeea6bfd048bbf83ba/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c65726f7573652f6c61726176656c2d7265706f7369746f7279)](https://packagist.org/packages/lerouse/laravel-repository)[![Innerbichler UK](https://camo.githubusercontent.com/921a8467aee38f056c79f59dd6af6d7ed9b736d83569af2a8ac3b350bb8116bf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f506f776572656425323042792d696e6e6572626963686c65722e756b2d6f72616e6765)](https://innerbichler.uk/)

Model Repository implementation for the Laravel framework ^v6.0 and above.

This package provides a structured framework to begin implementing a simple Model Repository structure in an existing Laravel application.

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

[](#installation)

The recommended method to install LaravelRepository is with [composer](https://getcomposer.org)

```
php composer require lerouse/laravel-repository
```

### Laravel without auto-discovery

[](#laravel-without-auto-discovery)

If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php

```
\Lerouse\LaravelRepository\LaravelRepositoryServiceProvider::class,
```

### Package configuration

[](#package-configuration)

Copy the package configuration to your local config directory.

```
php artisan vendor:publish --tag=repository-config
```

Usage
-----

[](#usage)

### Model Repository Location

[](#model-repository-location)

By default Laravel Model Repository presumes that model repositories are stored in the directory `app/repositories/model`. If you would like to change the directory your model repositories are stored change the namespace variable in the `config/repostiory.php` config file.

```
'namespace' => '\App\Repositories\Model',
```

For example if your model repositories are located in `app/model/repositories` update the namespace to

```
'namespace' => '\App\Model\Repositories',
```

### Creating a Repository

[](#creating-a-repository)

Repositories should extend the `Lerouse\LaravelRepository\EloquentRepository` method and implement the builder method which should return an instance of a `Illuminate\Database\Eloquent\Builder`.

```
