<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Relations\BelongsTo;

class EmployeeSalaryAssignment extends BaseModel
{
    protected $fillable = [
        'employee_id',
        'payroll_structure_id',
        'salary_type',
        'gross_salary',
        'effective_from',
    ];

    protected function casts(): array
    {
        return [
            'effective_from' => 'date',
            'gross_salary' => 'decimal:2',
        ];
    }

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

    public function payrollStructure(): BelongsTo
    {
        return $this->belongsTo(PayrollStructure::class);
    }
}
