<?php

namespace App\Http\Resources\Roles;

use Illuminate\Http\Resources\Json\JsonResource;

class RolePermissionResource extends JsonResource
{
    public function toArray($request): array
    {
        return [
            'permission_id' => (int) ($this->id ?? $this->permission_id ?? $this['id'] ?? $this['permission_id'] ?? 0),
            'name' => (string) ($this->name ?? $this['name'] ?? ''),
            'description' => $this->description ?? $this['description'] ?? null,
            'can_create' => (int) ($this->can_create ?? $this['can_create'] ?? 0),
            'can_read' => (int) ($this->can_read ?? $this['can_read'] ?? 0),
            'can_update' => (int) ($this->can_update ?? $this['can_update'] ?? 0),
            'can_delete' => (int) ($this->can_delete ?? $this['can_delete'] ?? 0),
            'can_manage' => (int) ($this->can_manage ?? $this['can_manage'] ?? 0),
        ];
    }
}
