From 1e8a4c2b70d6cfdd590b8c97fe6ff8856bcadaf7 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 30 Jan 2016 21:51:52 +1100 Subject: [PATCH] Working on products api --- app/Http/Controllers/ProductApiController.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ProductApiController.php b/app/Http/Controllers/ProductApiController.php index dd3fb214c4..e487ceec09 100644 --- a/app/Http/Controllers/ProductApiController.php +++ b/app/Http/Controllers/ProductApiController.php @@ -29,7 +29,14 @@ class ProductApiController extends BaseAPIController public function index() { - //stub + $products = Product::scope()->withTrashed(); + $products = $products->orderBy('created_at', 'desc')->paginate(); + + $transformer = new ProductTransformer(\Auth::user()->account, $this->serializer); + $data = $this->includeCollection($products, $transformer, 'products', $products->paginate()); + + return $this->response($data); + } public function getDatatable()