35 lines
1.2 KiB
PHP
35 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
use Illuminate\Http\Response;
|
|
|
|
class OrderResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
return [
|
|
'men_dian' => '大坪天街时代店',
|
|
'order_sn' => $this->order_sn,
|
|
'order_status' => $this->order_status ? ($this->pay_status ? ($this->shipping_status ? '已完成':'待取货'):'未支付'):'已取消',
|
|
'created_at' => $this->created_at->format('Y.m.d H:i'),
|
|
'order_goods' => OrderGoodsResource::collection($this->whenLoaded('goods')),
|
|
'order_prcie' => $this->ticket_value >0 ? number_format((intval($this->order_price*100) - intval($this->ticket_value*100))/100, 2):number_format($this->order_price, 2),
|
|
'is_reserve' => $this->is_reserve,
|
|
'reserve_time' => Carbon::parse($this->reserve_time)->toDateString(),
|
|
];
|
|
}
|
|
|
|
public function with($request)
|
|
{
|
|
return ['code' => Response::HTTP_OK, 'message' => ''];
|
|
}
|
|
} |