35 lines
1.1 KiB
PHP
35 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Endpoint\Api\Http\Resources\Dealer;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class DealerFansResource 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 [
|
|
'id' => $this->id,
|
|
'phone' => $this->phone,
|
|
'nickname' => (string) $this->whenLoaded('userInfo', function () {
|
|
return $this->userInfo->nickname;
|
|
}, ''),
|
|
'avatar' => (string) $this->whenLoaded('userInfo', function () {
|
|
return $this->userInfo->avatar;
|
|
}, ''),
|
|
'team_sales_value' => (string) $this->whenLoaded('dealer', function () {
|
|
return $this->dealer->team_sales_value;
|
|
}, 0),
|
|
'lvl_name' => (string) $this->whenLoaded('dealer', function () {
|
|
return $this->dealer->lvl_text;
|
|
}, '未知'),
|
|
];
|
|
}
|
|
}
|