<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class TaxSlab extends Model
{
    use SoftDeletes;

    protected $table = 'tax_slabs';
    protected $primaryKey = 'TSL_Id';

    public $timestamps = true;

    const CREATED_AT = 'created_at';
    const UPDATED_AT = 'updated_at';
    const DELETED_AT = 'deleted_at';

    protected $fillable = [
        'FY_ID',
        'From_Amt',
        'To_Amt',
        'TaxRate',
        'Tax_Name',
        'Code',           // New field
        'Stand_Deduc',    // New field
        'Cess',           // New field
        'Cess_Amount'     // New field
    ];

    protected $casts = [
        'TSL_Id' => 'integer',
        'FY_ID' => 'integer',
        'From_Amt' => 'integer',
        'To_Amt' => 'integer',
        'TaxRate' => 'integer',
        'Tax_Name' => 'string',
        'Code' => 'string',           // New field
        'Stand_Deduc' => 'integer',   // New field
        'Cess' => 'decimal:2',        // New field
        'Cess_Amount' => 'integer',   // New field
        'created_at' => 'datetime',
        'updated_at' => 'datetime',
        'deleted_at' => 'datetime'
    ];

    protected $dates = [
        'created_at',
        'updated_at',
        'deleted_at'
    ];

    protected $hidden = [
        'deleted_at'
    ];

    public function financialYear()
    {
        return $this->belongsTo(FyearMaster::class, 'FY_ID', 'FY_ID');
    }
}
