<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class EmployeeSalaryHistory extends Model
{
    use HasFactory;

    protected $fillable = [
        'user_id',
        'employee_id',
        'salary_type',
        'monthly_salary',
        'per_roz_rate',
        'overtime_rate',
        'effective_from',
        'effective_to',
        'change_note',
    ];

    protected $casts = [
        'monthly_salary'   => 'decimal:2',
        'per_roz_rate'     => 'decimal:2',
        'overtime_rate'    => 'decimal:2',
        'effective_from'   => 'date',
        'effective_to'     => 'date',
    ];

    public function user()
    {
        return $this->belongsTo(User::class);
    }

    public function employee()
    {
        return $this->belongsTo(Employee::class);
    }
}