37 lines
1.2 KiB
PHP
37 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Endpoint\Api\Http\Resources;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class OrderProfitResource extends JsonResource
|
|
{
|
|
public function toArray($request)
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'order_id' => $this->order_id,
|
|
'order' => $this->when($this->whenLoaded('order'), [
|
|
'id' => $this->order?->id,
|
|
'sn' => $this->order?->sn,
|
|
'total_amount' => $this->order ? $this->order->total_amount / 100 : 0
|
|
]),
|
|
'from_user_id' => $this->from_user_id,
|
|
'user_id' => $this->user_id,
|
|
// 'order' => OrderResource::make($this->whenLoaded('order')),
|
|
'from_user' => $this->when($this->whenLoaded('fromUser'), [
|
|
'id' => $this->fromUser?->id,
|
|
'phone' => $this->fromUser?->phone
|
|
]),
|
|
|
|
'growth_value' => (float)$this->growth_value,
|
|
'ratio' => $this->ratio,
|
|
'money' => (int)$this->money,
|
|
'sub_money' => (int)$this->sub_money,
|
|
'status' => $this->status,
|
|
'created_at' => $this->created_at->timestamp,
|
|
'paid_at' => $this->paid_at?->timestamp,
|
|
];
|
|
}
|
|
}
|