<?php

namespace Modules\HR\Transformers;

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

class SalaryRevisionResource extends JsonResource
{
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->id,
            'employee' => [
                'id' => $this->employee_id,
                'name' => $this->employee?->name,
            ],
            'old_salary' => $this->oldSalaryStructure ? $this->oldSalaryStructure?->basicItem?->calculation_value : null,

            'revision_type' => $this->revision_type,

            'revision_amount' => $this->revision_amount,

            'new_basic_salary' => $this->new_basic_salary,


            'salary_revision_status' => $this->salary_revision_status,

            'effective_date' => $this->effective_date,
            'reason' => $this->reason,
            'adjustment_direction' => $this->adjustment_direction,
            'employee_id' => $this->employee_id,
        ];
    }
}
