6
0
Fork 0
jiqu-library-server/app/Endpoint/Api/Http/Resources/BargainOrderLogResource.php

29 lines
855 B
PHP

<?php
namespace App\Endpoint\Api\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class BargainOrderLogResource 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 [
'nickname'=> (string) $this->whenLoaded('userInfo', function () {
return $this->userInfo->nickname;
}, ''),
'avatar'=> (string) $this->whenLoaded('userInfo', function () {
return $this->userInfo->avatar;
}, ''),
'bargain_amount' => $this->bargain_amount_format,
'created_at' => $this->created_at->format('Y-m-d H:i:s'),
];
}
}