コード例 #1
0
ファイル: BooksController.php プロジェクト: appkr/api
 /**
  * Display a listing of the resource.
  *
  * @param null $id
  * @return \Illuminate\Contracts\Http\Response
  */
 public function index($id = null)
 {
     // process v1.authors.books route
     if ('v1.authors.books' === \Route::currentRouteName()) {
         return json()->setMeta($this->meta)->withPagination(Author::find($id)->books()->latest()->paginate(5), new BookTransformer());
     }
     // Respond with pagination
     return json()->setMeta($this->meta)->withPagination($this->model->latest()->paginate(5), new BookTransformer());
     // Respond as a collection
     //return json()->setMeta($this->meta)->withCollection(
     //    $this->model->latest()->get(),
     //    new BookTransformer
     //);
 }