ekart/backend/app/Data/CartItemDTO.php
kusowl 1656739ecd feature: add and fetch products in cart api
- schema for cart and product
- define relationship, DTO, Resource and API collections
- Add post and get endpoint for cart api
2026-03-09 19:07:27 +05:30

33 lines
720 B
PHP

<?php
namespace App\Data;
use App\Contracts\OutputDataTransferObject;
final readonly class CartItemDTO implements OutputDataTransferObject
{
public function __construct(
public int $id,
public string $title,
public int $quantity,
public float $price,
public float $subtotal,
public string $image
) {}
/**
* @return array<string, mixed>
*/
public function toArray(): array
{
return [
'id' => $this->id,
'title' => $this->title,
'quantity' => $this->quantity,
'price' => $this->price,
'subtotal' => $this->subtotal,
'image' => $this->image,
];
}
}