42 lines
1.7 KiB
PHP
42 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Endpoint\Api\Http\Resources;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class OfflineOrderResource 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,
|
|
'user_id' => $this->user_id,
|
|
'store_id' => $this->store_id,
|
|
'store' => StoreResource::make($this->whenLoaded('store')),
|
|
'user' => UserResource::make($this->whenLoaded('user')),
|
|
'staff_id' => $this->staff_id,
|
|
'sn' => $this->sn,
|
|
'products_total_amount' => bcdiv($this->products_total_amount, 100, 2),
|
|
'discount_reduction_amount' => bcdiv($this->discount_reduction_amount, 100, 2),
|
|
'points_deduction_amount' => bcdiv($this->points_deduction_amount, 100, 2),
|
|
'coupon_discount_amount' => bcdiv($this->coupon_discount_amount, 100, 2),
|
|
'payment_amount' => bcdiv($this->payment_amount, 100, 2),
|
|
'status' => $this->status,
|
|
'status_text' => $this->status->text(),
|
|
'payment_time' => $this->payment_time?->format('Y-m-d H:i:s'),
|
|
'created_at' => $this->created_at?->format('Y-m-d H:i:s'),
|
|
'payment_sn' => $this->payment_sn,
|
|
'user_remark' => $this->user_remark,
|
|
'staff_remark' => $this->staff_remark,
|
|
'coupon_id' => $this->coupon_id,
|
|
'items' => OfflineOrderItemResource::collection($this->whenLoaded('items')),
|
|
];
|
|
}
|
|
}
|