<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class TaxRate extends Model
{
    use HasFactory;

    protected $fillable = [
        'state_name',
        'state_code',
        'rate',
        'description',
        'country_code',
        'country',
        'active'
    ];

    protected $casts = [
        'rate' => 'float',
        'active' => 'boolean'
    ];

    // Helper method to format rate
    public function getFormattedRateAttribute()
    {
        return number_format($this->rate, 2) . '%';
    }

    // Helper method for status
    public function getStatusAttribute()
    {
        return $this->active ? 'Active' : 'Inactive';
    }

    // Helper method for status badge color
    public function getStatusColorAttribute()
    {
        return $this->active ? 'success' : 'danger';
    }
}