motty / laravel-repository by motty

Laravel - Repository Design Pattern Implementation
50
2
1
Package Data
Maintainer Username: motty
Maintainer Contact: israel@motty.io (Israel Sotomayor)
Package Create Date: 2015-06-30
Package Last Update: 2015-06-30
Language: PHP
License: MIT
Last Refreshed: 2024-11-21 03:01:43
Package Statistics
Total Downloads: 50
Monthly Downloads: 1
Daily Downloads: 0
Total Stars: 2
Total Watchers: 1
Total Forks: 0
Total Open Issues: 0

Laravel - Repository Design Pattern Implementation

Installation

Run the following command from you terminal:

composer require motty/laravel-repository:~0.1.0

or add this to require section in your composer.json file:

"motty/laravel-repository: ~0.1.0"

then run composer update

Available Methods

The following methods are available:

Motty\Laravel\Repository\Contracts\Repository
public function all($columns = ['*']);
public function lists($value, $key = null);
public function paginate($perPage = 15, $columns = ['*']);
public function findBy($attribute, $value, $columns = ['*']);
public function findManyBy($attribute, $value, $columns = ['*']);
Motty\Laravel\Repository\Contracts\Model
public function newQuery();
Motty\Laravel\Repository\Contracts\EagerLoading
public function with($relations);
Motty\Laravel\Repository\Contracts\Crudable
public function create(array $attributes);
public function find($id, array $columns = ['*']);
public function update(array $data, $id, $attribute = 'id');
public function delete($ids = null);
Motty\Laravel\Repository\Contracts\Criteria
public function skipCriteria($status = true);
public function getCriteria();
public function getByCriteria(BaseCriteria $criteria);
public function pushCriteria(BaseCriteria $criteria);
public function applyCriteria();

Tip and Tricks

If you wanna use joins just create them as a criteria and inject it into the repository

Note: this could help with any other complex query