<?php

namespace App\Http\Resources\Roles;

use Illuminate\Http\Resources\Json\JsonResource;

class RoleResource extends JsonResource
{
    public function toArray($request): array
    {
        return [
            'id' => (int) ($this->id ?? $this['id'] ?? 0),
            'name' => (string) ($this->name ?? $this['name'] ?? ''),
            'slug' => (string) ($this->slug ?? $this['slug'] ?? ''),
            'description' => $this->description ?? $this['description'] ?? null,
            'dashboard_route' => (string) ($this->dashboard_route ?? $this['dashboard_route'] ?? ''),
            'priority' => (int) ($this->priority ?? $this['priority'] ?? 0),
            'is_active' => (int) ($this->is_active ?? $this['is_active'] ?? 0),
            'user_count' => $this->user_count ?? $this['user_count'] ?? null,
            'created_at' => $this->created_at ?? $this['created_at'] ?? null,
            'updated_at' => $this->updated_at ?? $this['updated_at'] ?? null,
        ];
    }
}
