<?php

namespace Modules\Mall\Http\Resources\Api\Order;

use Illuminate\Http\Resources\Json\JsonResource;
use Modules\Mall\Http\Resources\Api\Shop\ShopBaseInfoResource;

class OrderResource extends JsonResource
{

    public function toArray($request): array
    {
        return [
            'order_no'         => $this->order_no,
            'shop'             => new ShopBaseInfoResource($this->shop),
            'amount'           => $this->amount,
            'freight'          => $this->freight,
            'total'            => $this->total,
            'type'             => $this->type_text,
            'state'            => $this->state_text,
            'can'              => $this->getCanAction(),
            'is_logistic_show' => $this->is_logistic_show,
            'items'            => OrderItemResource::collection($this->items),
            'express'          => new OrderExpressResource($this->express),
            'remark'           => (string) $this->remark,
            'expired_at'       => (string) $this->expired_at,
            'paid_at'          => (string) $this->paid_at,
            'created_at'       => (string) $this->created_at,
        ];
    }

}
