From 45100987f3e16d34b3b3c681be5e9f7a2b452ce9 Mon Sep 17 00:00:00 2001 From: Shakil Alam Date: Thu, 19 Mar 2020 12:32:13 +0530 Subject: [PATCH] toJson return with model if available toJson Method will return CartItem's model if available. so it can be used in Vue Component --- src/CartItem.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/CartItem.php b/src/CartItem.php index cf91801d..19a0a241 100644 --- a/src/CartItem.php +++ b/src/CartItem.php @@ -384,6 +384,9 @@ public function toArray() */ public function toJson($options = 0) { + if(isset($this->associatedModel){ + return json_encode(array_merge($this->toArray(), ['model' => $this->model]), $options); + } return json_encode($this->toArray(), $options); }