Created
July 23, 2018 12:56
-
-
Save ashoaib/5773387fa65ce243e8d1e041f38f0300 to your computer and use it in GitHub Desktop.
Accessing data using the repository pattern in Chef
This file contains hidden or 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\Resources\Order; | |
use \App\Resources\Order\Order; | |
use \Gousto\Requesto\Repository; | |
/** | |
* Class OrderRepository | |
* | |
* @package App\Resources\Order | |
*/ | |
class OrderRepository extends Repository implements OrderRepositoryInterface | |
{ | |
/** | |
* @var string | |
* | |
* The model class name to be used by the repository. | |
*/ | |
protected $model_name = Order::class; | |
/** | |
* @param string $user_id | |
* | |
* @return Collection | |
* | |
* Returns a collection of orders for the given user. | |
*/ | |
public function getByUserId($user_id) | |
{ | |
return $this->model()->where('user_id', $user_id)->get(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment