Skip to content

Commit

Permalink
toJson return with model if available
Browse files Browse the repository at this point in the history
toJson Method will return CartItem's model if available. so it can be used in Vue Component
  • Loading branch information
Shakil Alam authored Mar 19, 2020
1 parent 0e93e13 commit 4510098
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/CartItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 4510098

Please sign in to comment.