<?php

namespace App\Models;

use App\Traits\BelongsToTenant;
use Illuminate\Database\Eloquent\Model;

class EmployeeSalaryStructure extends Model
{
    use BelongsToTenant;

    protected $fillable = ['tenant_id', 'employee_id', 'payroll_group_id', 'effective_from', 'effective_to', 'basic_salary', 'housing_allowance', 'transport_allowance', 'other_fixed_allowance', 'variable_allowance', 'overtime_eligible', 'overtime_hourly_rate', 'currency', 'payment_method', 'components_json', 'created_by', 'change_reason'];

    protected $casts = ['effective_from' => 'date', 'effective_to' => 'date', 'basic_salary' => 'decimal:2', 'housing_allowance' => 'decimal:2', 'transport_allowance' => 'decimal:2', 'other_fixed_allowance' => 'decimal:2', 'variable_allowance' => 'decimal:2', 'overtime_eligible' => 'boolean', 'overtime_hourly_rate' => 'decimal:4', 'components_json' => 'array'];

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

    public function payrollGroup()
    {
        return $this->belongsTo(PayrollGroup::class);
    }
}
