From b1b0612fe39fa39f0a3763d1e772984357e544c1 Mon Sep 17 00:00:00 2001 From: saparatayev Date: Thu, 16 Jun 2022 13:04:57 +0500 Subject: [PATCH] unit property in my products json --- .../apigenerator/controllers/api/ProductsApiController.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/ahmadfatoni/apigenerator/controllers/api/ProductsApiController.php b/plugins/ahmadfatoni/apigenerator/controllers/api/ProductsApiController.php index f167ee670..0e2f820ef 100644 --- a/plugins/ahmadfatoni/apigenerator/controllers/api/ProductsApiController.php +++ b/plugins/ahmadfatoni/apigenerator/controllers/api/ProductsApiController.php @@ -463,6 +463,12 @@ class ProductsAPIController extends Controller 'images:attachment_id,attachment_type,disk_name,file_name') ->orderBy('updated_at', 'desc') ->paginate($perPage); + + if($products) { + foreach ($products as $product) { + $product->unit = new MeasureResource($product->measure); + } + } } catch (\Throwable $th) { return $this->helpers->apiArrayResponseBuilder(500, 'server error', ['message' => 'Something went wrong']); }