32 lines
1.0 KiB
PHP
32 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Endpoint\Api\Http\Resources;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class OfflineOrderPreviewResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'store_id' => $this->store_id,
|
|
'store' => StoreResource::make($this->whenLoaded('store')),
|
|
'payload' => $this->payload,
|
|
'remark' => $this->remark,
|
|
'coupon_id' => $this->coupon_id,
|
|
'coupon' => UserCouponResource::make($this->whenLoaded('coupon')),
|
|
'order' => OfflineOrderResource::make($this->whenLoaded('order')),
|
|
'created_at' => $this->created_at?->format('Y-m-d H:i:s'),
|
|
'orders' => OfflineOrderResource::collection($this->whenLoaded('orders')),
|
|
'qrcode' => $this->qrcode,
|
|
];
|
|
}
|
|
}
|