<?php

namespace App\Http\Resources\Users;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class UserWithRolesResource extends JsonResource
{
    public function toArray(Request $request): array
    {
        return [
            'user' => $this->resource['user'] ?? null,
            'roles' => $this->resource['roles'] ?? [],
            'role_ids' => $this->resource['role_ids'] ?? [],
            'parent_type' => $this->resource['parent_type'] ?? '',
            'second_from_parents' => $this->resource['second_from_parents'] ?? '',
        ];
    }
}
