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

ActiveLibrary

atrakeur/repository
===================

A implementation of the repository pattern for laravel that decouple Eloquent models using standart php objects

9305PHP

Since Jan 10Pushed 11y ago2 watchersCompare

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

READMEChangelogDependenciesVersions (2)Used By (0)

Laravel repository
==================

[](#laravel-repository)

Goals
-----

[](#goals)

- Provide a common interface for a repository implementation using laravel framework.
- Provide you a good starting point to create simple and maintainable laravel applications.
- Encourage good behavior using repository pattern with a few lines of code
- Simplify your code by abstracting complex behavior
- Cleaning up your models and controllers. (and keeping repositories clean btw!)

What does this package
----------------------

[](#what-does-this-package)

The point here is to abstract Eloquent models by using standard php objects (stdClass and arrays). This way, you can switch later to another data source such as MongoDB without touching your models. All the bloat of convertion is already handled out of your code.

This package handle fetching Eloquent data, and converting them to plain PHP objects. More data providers will be added later as they are needed.

This package enable you to use the same syntax for displaying data as with eloquent models ($model-&gt;data syntax) unlike the toArray approach.

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

[](#installation)

### Import the package

[](#import-the-package)

To install, simply add the following line to your composer .json and run composer update:

```
"atrakeur/repository": "dev-master"
```

Then add the following service provider to your app.php:

```
'Atrakeur\Repository\RepositoryServiceProvider',
```

And finally publish the package config:

```
php artisan config:publish atrakeur/repository

```

### Create your first repository

[](#create-your-first-repository)

A basic repository definition look like that:

```
