<?php

namespace Modules\User\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class RelationResource extends JsonResource
{

    public function toArray($request): array
    {
        return [
            'user_id'    => $this->user->id,
//            'username'   => substr_replace($this->user->username, '****', 3, 4),
            'username'   => $this->user->username,
            'nickname'   => $this->user->info->nickname ?? '',
            'avatar'     => $this->user->info->avatar ?? '',
            'sex'        => $this->user->case ? $this->user->case->sex_text : '--',
            'identity'   => new UserIdentityBaseResource($this->user->identities->first()),
            'created_at' => (string) $this->user->created_at,
        ];
    }

}