コード例 #1
0
ファイル: AuthorTransformer.php プロジェクト: appkr/api
 /**
  * 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());
 }