<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Relations\BelongsTo;

class SalaryIncrement extends BaseModel
{
    protected $fillable = [
        'employee_id',
        'previous_salary',
        'new_salary',
        'increment_percentage',
        'effective_date',
        'reason',
        'status',
        'approved_by',
        'approved_at',
    ];

    protected function casts(): array
    {
        return [
            'effective_date' => 'date',
            'previous_salary' => 'decimal:2',
            'new_salary' => 'decimal:2',
            'increment_percentage' => 'decimal:2',
            'approved_at' => 'datetime',
        ];
    }

    public function employee(): BelongsTo
    {
        return $this->belongsTo(User::class, 'employee_id');
    }

    public function approvedBy(): BelongsTo
    {
        return $this->belongsTo(User::class, 'approved_by');
    }
}
