34 lines
1.0 KiB
PHP
34 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources\Api\V1\Order;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class OrderItemResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'product' => [
|
|
'id' => $this->product_id,
|
|
'name' => $this->product->name,
|
|
'thumbnail' => $this->product->thumbnail(),
|
|
'images_400x400' => $this->product->getFirstMediaUrl('uploads', 'thumb400x400'),
|
|
'images_800x800' => $this->product->getFirstMediaUrl('uploads', 'thumb800x800'),
|
|
'images_1200x1200' => $this->product->getFirstMediaUrl('uploads', 'thumb1200x1200'),
|
|
],
|
|
'order' => [
|
|
'id' => $this->order_id,
|
|
],
|
|
'quantity' => $this->quantity,
|
|
'unit_price_amount' => $this->unit_price_amount,
|
|
];
|
|
}
|
|
}
|