Download the PHP package guilhermegonzaga/repository without Composer
On this page you can find all versions of the php package guilhermegonzaga/repository. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download guilhermegonzaga/repository
More information about guilhermegonzaga/repository
Files in guilhermegonzaga/repository
Package repository
Short Description Repositories for Laravel 5 which is used to abstract the database layer.
License MIT
Informations about the package repository
Laravel Repositories
Repository is a design pattern for Laravel 5 which is used to abstract the database layer.
It makes your application easier to be maintained.
Installation
Laravel (5.1 and 5.2)
Execute the following command to get the latest version of the package:
Methods
Usage
Create your repository class.
Note that your repository class must extend and implement method.
By implementing method you telling repository what model class you want to use.
Create your model:
Finally, use the repository in the controller:
Usage methods
Find all results:
Find first result:
Find all results with pagination:
Find result by id:
Loading the model relationships:
Find result by multiple fields:
Find using custom scope (nested):
Get random results:
Enable/disable method in repository:
Create new entry:
Update entry:
Delete entry:
Criteria
This package makes it very easy to work with scopes/criteria.
Create classes to abstract these rules and make them reusable:
Receiving arguments:
Use the criteria in the controller:
Other methods
In addition to the methods that are available in this package, you can call any method in default of Eloquent Builder. When you call a method that does not exist in this package, it's automatically called on Eloquent Builder.
Ex:
Credits
This package is largely inspired by this great package by @andersao.