Skip to content

Instantly share code, notes, and snippets.

@ashoaib
Created July 23, 2018 12:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashoaib/5773387fa65ce243e8d1e041f38f0300 to your computer and use it in GitHub Desktop.
Save ashoaib/5773387fa65ce243e8d1e041f38f0300 to your computer and use it in GitHub Desktop.
Accessing data using the repository pattern in Chef
<?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