37 lines
1.3 KiB
PHP
37 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Modules\Mall\Http\Resources\Api\Order;
|
|
|
|
use App\Api\Resources\BaseCollection;
|
|
use Modules\Mall\Http\Resources\Api\Shop\ShopBaseInfoResource;
|
|
|
|
class RefundCollection extends BaseCollection
|
|
{
|
|
|
|
public function toArray($request): array
|
|
{
|
|
return [
|
|
'data' => $this->collection->map(function ($refund) {
|
|
return [
|
|
'refund_no' => $refund->refund_no,
|
|
'order_no' => $refund->order->order_no,
|
|
'shop' => new ShopBaseInfoResource($refund->shop),
|
|
'refund_total' => $refund->refund_total,
|
|
'actual_total' => $refund->actual_total,
|
|
'state' => [
|
|
'state' => $refund->state,
|
|
'text' => $refund->status_text,
|
|
'remark' => $refund->state_text,
|
|
],
|
|
'can' => collect($refund->transitions())->map(function ($item) {
|
|
return $item->getName();
|
|
}),
|
|
'created_at' => (string) $refund->created_at,
|
|
'items' => RefundItemsResource::collection($refund->items),
|
|
];
|
|
}),
|
|
'page' => $this->page(),
|
|
];
|
|
}
|
|
|
|
} |