<?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', 'code', 'component_type', 'name', 'calculation', 'amount', 'is_taxable', 'sort_order',
    ];

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

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