Exemple #1
0
 /**
  * Include books.
  *
  * @param \Appkr\Api\Example\Author     $author
  * @param \League\Fractal\ParamBag|null $params
  * @return \League\Fractal\Resource\Collection
  */
 public function includeBooks(Author $author, ParamBag $params = null)
 {
     $transformer = new BookTransformer($params);
     $parsed = $transformer->getParsedParams();
     $books = $author->books()->limit($parsed['limit'])->offset($parsed['offset'])->orderBy($parsed['sort'], $parsed['order'])->get();
     return $this->collection($books, new BookTransformer());
 }
Exemple #2
0
 /**
  * Include books.
  *
  * @param \Appkr\Api\Example\Author $author
  * @param \League\Fractal\ParamBag|null $paramBag
  * @return \League\Fractal\Resource\Collection
  */
 public function includeBooks(Author $author, ParamBag $paramBag = null)
 {
     $transformer = new BookTransformer($paramBag);
     $books = $author->books()->limit($transformer->getLimit())->offset($transformer->getOffset())->orderBy($transformer->getSortKey(), $transformer->getSortDirection())->get();
     return $this->collection($books, new BookTransformer());
 }