Files
water_new/modules/Mall/Http/Resources/Api/Order/RefundResource.php
2023-03-08 09:16:04 +08:00

41 lines
1.6 KiB
PHP

<?php
namespace Modules\Mall\Http\Resources\Api\Order;
use Illuminate\Http\Resources\Json\JsonResource;
class RefundResource extends JsonResource
{
public function toArray($request): array
{
return [
'refund_id' => $this->id,
'refund_no' => $this->refund_no,
'order_no' => $this->order->order_no,
'state' => [
'state' => $this->state,
'text' => $this->status_text,
'remark' => $this->state_text,
],
'refund_total' => $this->refund_total,
'actual_total' => $this->actual_total,
'order' => [
'order_id' => $this->order->id,
'order_no' => $this->order->order_no,
'paid_at' => $this->order->paid_at ? $this->order->paid_at->toDateTimeString() : '',
'deliver_at' => $this->order->express->deliver_at ? $this->order->express->deliver_at->toDateTimeString() : '',
'receive_at' => $this->order->express->receive_at ? $this->order->express->receive_at->toDateTimeString() : '',
],
'items' => RefundItemsResource::collection($this->items),
'can' => collect($this->transitions())->map(function ($item) {
return $item->getName();
}),
'log' => new RefundLogResource($this->logs()->oldest()->first()),
'created_at' => $this->created_at->toDateTimeString(),
'updated_at' => $this->updated_at->toDateTimeString(),
];
}
}