26 lines
857 B
PHP
26 lines
857 B
PHP
<?php
|
|
|
|
namespace App\Endpoint\Api\Http\Resources;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class FansResource 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 [
|
|
'phone' => $this->phone,
|
|
'nickname' => (string) $this->whenLoaded('userInfo', $this->userInfo->nickname, ''),
|
|
'avatar' => (string) $this->whenLoaded('userInfo', $this->userInfo->avatar, ''),
|
|
'value' => (string) $this->whenLoaded('userInfo', $this->userInfo->growth_value, 0),
|
|
'level_name' => (string) $this->whenLoaded('userInfo', $this->userInfo->agent_level_name, '未知'),
|
|
];
|
|
}
|
|
}
|