cart product adn super attributes

This commit is contained in:
merdan 2022-02-28 17:32:19 +05:00
parent 10eacef56b
commit 2392b68839
1 changed files with 4 additions and 6 deletions

View File

@ -15,15 +15,13 @@ class CartItemProduct extends JsonResource
*/
public function toArray($request)
{
/* assign product */
$product = $this->product ? $this->product : $this;
return [
'id' => $this->id,
'name' => $product->name,
'images' => ProductImage::collection($product->images),
'name' => $this->name,
'images' => ProductImage::collection($this->images),
/* super attributes */
$this->mergeWhen(!empty($this->product->parent), [
'super_attributes' => $this->super_attributes($this->product->parent->super_attributes),
$this->mergeWhen(!empty($this->parent && $this->parent->super_attributes), [
'super_attributes' => $this->super_attributes($this->parent->super_attributes),
]),
];
}