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

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

ratno/laravel-repositories
==========================

Laravel repositories using the native Eloquent functions

2.0.6(7mo ago)0478MITPHP

Since Oct 10Pushed 7mo agoCompare

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

READMEChangelogDependenciesVersions (18)Used By (0)

Laravel Eloquent Repositories
=============================

[](#laravel-eloquent-repositories)

> Heads up! This is not yet another base class where there are some methods trying to act as Eloquent replacement. This is an implementation where you can use all Eloquent features on a custom class!

Using Repositories in Laravel can be a bit confusing. If you create custom classes functioning as repositories you can't really use Eloquent anymore, which is one of the best features of Laravel. That's why I was looking for another way for using the repository pattern in Laravel. I came up with this approach and thought I would share it.

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

[](#installation)

Just install it through Composer:

```
composer require mratiebatie/laravel-repositories

```

After installation you can start using the repository pattern with Laravel.

Make a repository class
-----------------------

[](#make-a-repository-class)

This package provide a new Artisan command to create a repository class. All the classes will be generated on the `App\Repositories` folder, if this folder is missing, it will be generated automatically.

```
php artisan make:repository ProductRepository

```

You can use the `--model` option to define the Eloquent model that will be linked to this repository.

```
php artisan make:repository ProductRepository --model=App\\Product

```

Don't forget to write the **full namespace** of your model, using '\\\\' as the separator.

Example
-------

[](#example)

In this example I assume that you already have a model named Product. Used the command

`php artisan make:repository ProductRepository --model=App\\Models\\Product`

```
