<?php

namespace App\Models;

use App\Models\BaseModel;
use App\Models\TaxSlab;

class IncomeTaxPlan extends BaseModel
{
    protected $table = 'income_tax_plans';
    protected $default = ['id', 'xid', 'plan_name','plan_code'];
    protected $guarded = ['id', 'created_at', 'updated_at', 'default'];

    protected $hidden = ['id'];

    protected $appends = ['xid'];

    protected $filterable = ['id', 'plan_name','plan_code'];

    protected $fillable = [
        'plan_name',
        'plan_code',
        'allow_deductions',
        'standard_deduction',
        'description',
        'effective_from',
        'effective_to',
        'is_active',
    ];

    protected $casts = [
        'allow_deductions' => 'boolean',
        'is_active'        => 'boolean',
        'effective_from'   => 'date',
        'effective_to'     => 'date',
    ];

    public function taxSlabs()
    {
        return $this->hasMany(TaxSlab::class, 'plan_id', 'id')->orderBy('slab_no');
    }
}
?>