<?php

namespace App\Modules\HR\Payroll\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class SalaryStructureComponent extends Model
{
    protected $table = 'hr_salary_structure_components';

    protected $fillable = [
        'structure_id', 'component_type', 'name', 'calculation', 'amount', 'is_taxable',
    ];

    protected function casts(): array
    {
        return ['amount' => 'decimal:2', 'is_taxable' => 'boolean'];
    }

    public function structure(): BelongsTo
    {
        return $this->belongsTo(SalaryStructure::class, 'structure_id');
    }
}
