41 lines
1.2 KiB
PHP
41 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class UserResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
if (!isset($this->id)) {
|
|
return [];
|
|
}
|
|
|
|
return [
|
|
'user_id' => $this->id,
|
|
'nickname' => $this->info->nickname,
|
|
'mobile' => $this->info->mobile,
|
|
'avatar' => $this->info->avatar,
|
|
'sex' => $this->info->sex,
|
|
'company' => $this->info->company,
|
|
'area' => $this->info->area,
|
|
'identity_id' => $this->identity->identity_id ?? 0,
|
|
'identity_text' => $this->identity_text,
|
|
'vip_end_at' => $this->vip_end_at ? $this->vip_end_at->toDateTimeString() : '',
|
|
'needBuy' => $this->needBuy(),
|
|
'canCompany' => empty($this->info->company),
|
|
'company' => [
|
|
'company' => $this->info->company,
|
|
'area' => $this->info->area,
|
|
],
|
|
];
|
|
}
|
|
}
|