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

33 lines
978 B
PHP

<?php
namespace App\Endpoint\Api\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class UserBalanceResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
if (is_null($this->resource)) {//没有钱包数据时默认数据
return [
'balance'=> '0.00',
// 'total_expenses'=> $this->total_expenses,
// 'total_revenue' => $this->total_revenue,
// 'withdrawable' => $this->withdrawable,
];
}
return [
'balance'=>$this->balance_format,
// 'total_expenses'=> $this->total_expenses,
// 'total_revenue' => $this->total_revenue,
// 'withdrawable' => $this->withdrawable,
];
}
}