Last active
November 22, 2016 03:22
-
-
Save cuonghuynh/db3de30aa8af37ef2248031aad1370da to your computer and use it in GitHub Desktop.
Repository pattern in laravel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Contracts\Repository; | |
interface IRepository | |
{ | |
/** | |
* Get all | |
* @param array $columns | |
* @return mixed | |
*/ | |
public function all($columns = ["*"]); | |
/** | |
* Paginate all | |
* @param integer $perPage | |
* @param array $columns | |
* @return mixed | |
*/ | |
public function paginate($perPage = 15, $columns = ['*']); | |
/** | |
* Create new model | |
* @param array $data | |
* @return mixed | |
*/ | |
public function create($data = []); | |
/** | |
* Update model by the given ID | |
* @param array $data | |
* @param integer $id | |
* @param string $attribute | |
* @return mixed | |
*/ | |
public function update($data = [], $id, $attribute = 'id'); | |
/** | |
* Delete model by the given ID | |
* @param integer $id | |
* @return boolean | |
*/ | |
public function delete($id); | |
/** | |
* Find model by the given ID | |
* @param integer $id | |
* @param array $columns | |
* @return mixed | |
*/ | |
public function find($id, $columns = ['*']); | |
/** | |
* Find model by a specific column | |
* @param string $field | |
* @param mixed $value | |
* @param array $columns | |
* @return mixed | |
*/ | |
public function findBy($field, $value, $columns = ['*']); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment