29 lines
911 B
PHP
29 lines
911 B
PHP
<?php
|
|
|
|
namespace App\Endpoint\Api\Http\Resources\Dealer;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class OrderResource 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 [
|
|
'sn' =>$this->sn,
|
|
'product'=>OrderProductResource::collection($this->products),
|
|
'total_amount' => $this->total_amount,
|
|
'created_at' => $this->created_at->toDateTimeString(),
|
|
'status' => $this->status,
|
|
'pay_info' => $this->pay_info??$this->consignor->dealer->pay_info,
|
|
'pay_image'=> $this->pay_image,
|
|
'is_consignor' => $request->user()->id == $this->consignor_id, //是否发货人身份
|
|
];
|
|
}
|
|
}
|