src/Http/Resources/UserResource.php
public function toArray($request)
    {
        /** @var \Unite\UnisysApi\Models\User $this->resource */
        return [
            'id'                => $this->id,
            'name'              => $this->name,
            'surname'           => $this->surname,
            'email'             => $this->email,
            'username'          => $this->username,
            'roles'             => RoleResource::collection($this->roles()->get(['id', 'name']))
        ];
    }
public function toArray($request)
    {
        /** @var \Unite\UnisysApi\Models\User $this->resource */
        return [
            'id'                => $this->id,
            'name'              => $this->name,
            'surname'           => $this->surname,
            'email'             => $this->email,
            'username'          => $this->username,
            'roles'             => RoleResource::collection($this->roles()->get(['id', 'name']))
        ];
    }
Transform the resource into an array.

@param  \Illuminate\Http\Request
@return array