unit property in my products json

This commit is contained in:
saparatayev 2022-06-16 13:04:57 +05:00
parent 899884d8a7
commit b1b0612fe3
1 changed files with 6 additions and 0 deletions

View File

@ -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']);
}