30 lines
988 B
PHP
30 lines
988 B
PHP
<?php
|
|
|
|
namespace App\Endpoint\Api\Http\Resources\Dealer;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class OrderSimpleResource 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,
|
|
'sn' =>$this->sn,
|
|
'total_amount' => $this->total_amount,
|
|
'paied_time' => $this->paied_time?->toDateTimeString(),
|
|
'shippinged_time' => $this->shippinged_time?->toDateTimeString(),
|
|
'created_at' => $this->created_at->toDateTimeString(),
|
|
'status' => $this->status,
|
|
'is_consignor' => $request->user()->id == $this->consignor_id, //是否发货人身份
|
|
'products' => OrderProductResource::collection($this->whenLoaded('products')),
|
|
];
|
|
}
|
|
}
|