knash94 / repositories
Laravel repositories with base repositories for eloquent with a cache decorator
This package is auto-updated.
Last update: 2020-01-22 11:25:30 UTC
README
Repositories is a package for Laravel that makes it much easier to create repositories for Laravel, whether you want just a Eloquent repository or an eloquent repository with cache.
##Installation Run the following command from your terminal
composer require knash94/repositories
Open app/config with your favorite text editor and add the following line under package service providers
Knash94\Repositories\RepositoryServiceProvider::class,
##Usage To create a basic repository without cache
php artisan make:repository exampleRepository
or with cache
php artisan make:repository exampleRepository --with-cache
Afterwards, open the new generated file under app/repositories/exampleRepository.php and find
protected $model;
and replace it with your models class, for example
protected $model = User::class;
After that you're all ready to go!
##Repository methods
public function all(); public function count(); public function countWhere($column, $value); public function findById($id); public function updateById($id, array $attributes); public function create(array $attributes); public function get(); public function groupBy($columns); public function limit($limit); public function orderBy($column, $direction = 'asc'); public function select($columns = ['*']); public function where($column, $operator = null, $value = null, $boolean = 'and'); public function createMultiple(array $data); public function with($relations);