Download the PHP package tlikai/laravel-repository without Composer
On this page you can find all versions of the php package tlikai/laravel-repository. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tlikai/laravel-repository
More information about tlikai/laravel-repository
Files in tlikai/laravel-repository
Package laravel-repository
Short Description Laravel Repository pattern implemention
License MIT
Homepage https://github.com/tlikai/laravel-repository
Informations about the package laravel-repository
Laravel Repository
Laravel Repository is a package for Laravel 5.7 which is used to abstract the database layer. This makes applications much easier to maintain.
The main differnece between this project and others is:
- use eloquent model as an entity
- put business logic into eloquent model
- always use repository to persist eloquent model,
$repository->save($model)
; - don't call
$model->save, $model->update, $model->delete
, etc... persistence method directly, always use$repository->save($model)
Installation
Run the following command from you terminal:
or add this to require section in your composer.json file:
then run
Usage
First, create your repository class. Note that your repository class MUST extend and implement model() method
By implementing method you telling repository what model class you want to use. Now, create model:
And finally, use the repository in the controller:
Available Methods
The following methods are available:
Uniqueway\Repositories\Contracts\RepositoryInterface
Uniqueway\Repositories\Contracts\CriteriaInterface
Example usage
Find film by id;
Create a new film:
Update existing film:
Delete film:
Uniqueway\Repositories\Criteria\Criteria``` class.
Here is a simple criteria:
Now, inside you controller class you call pushCriteria method: