Download the PHP package reynholm/laravel-repositories without Composer
On this page you can find all versions of the php package reynholm/laravel-repositories. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download reynholm/laravel-repositories
More information about reynholm/laravel-repositories
Files in reynholm/laravel-repositories
Package laravel-repositories
Short Description Provides an easy way to create your laravel repositories
License MIT
Informations about the package laravel-repositories
Laravel Repositories
Repository pattern for Laravel
Installation and Configuration
Add this to your composer.json
Abandoned!
This package is abandoned as you can see on packagist. I moved to python and I have no time for keeping this repo up to date with Laravel. Feel free to fork it and maintaining it yourself.
Notice
I think that you can use it even that is on an early stage, but I may make some breaking changes so if you don't want any surprises just don't put "dev-master" or an asterisk as your composer version. Be smart!
If you put your version like on the above example you will not get any breaking changes.
Usage
Simply extend the abstract class Reynholm\LaravelRepositories\Repository\LaravelRepository
Example
Fetch Mode
You can also choose the fetcher that you like the most or create your own. You can select the one that you prefer from the LaravelRepositoryInterface constants. Example:
So the repository will return a Illuminate\Support\Collection with objects.
Currently implemented methods:
Timestamps
You can add timestamps adding the $timestamps = true property:
By default it will manage created_at and updated_at fields. You can override the created and updated fields using the following properties:
Validation
You can validate your data with the validate methods. Specify the rules of your repository in the rules property:
Examples:
Extending the repository with your custom methods
You can grab the builder instance with
to create your custom repository methods.
Example
A best practice would be to create a new interface for MyUsersRepository with all of the new methods that you are going to add.
And then implement it on your repository:
So if you want to change the implementation you would need to implement the MyUsersRepositoryInterface and LaravelRepositoryInterface.
Future
More features coming soon
All versions of laravel-repositories with dependencies
illuminate/support Version 4.*
illuminate/database Version 4.*
lisachenko/go-aop-php Version 0.5.0