40 lines
1.4 KiB
PHP
40 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Endpoint\Api\Http\Resources;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class AfterSaleResource 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,
|
|
'order_sn' => $this->order->sn,
|
|
'order_total_amount' => $this->order->total_amount,
|
|
'product'=>[
|
|
'name' => $this->orderProduct->name,
|
|
'cover' => $this->orderProduct->cover,
|
|
'sell_price' => bcdiv($this->orderProduct->total_amount, $this->orderProduct->quantity * 100, 2),
|
|
'num'=> $this->num,
|
|
'is_gift' => $this->orderProduct->isGift(),
|
|
'total_amount' => $this->orderProduct->total_amount,
|
|
],
|
|
'state' => $this->after_sale_state,
|
|
'type' => $this->type,
|
|
'images' => $this->images,
|
|
'description' => $this->description,
|
|
'remarks' => $this->remarks,
|
|
'created_at' => $this->created_at->toDateTimeString(),
|
|
'amount'=> $this->amount_format,
|
|
// 'logs' => AfterSaleLogResource::make($this->whenLoaded('logs')),
|
|
];
|
|
}
|
|
}
|