<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class CompanyUnit extends Model
{
    protected $fillable = ['company_id', 'code', 'name', 'is_gst'];

    protected $casts = ['is_gst' => 'boolean'];

    public function company(): BelongsTo
    {
        return $this->belongsTo(Company::class);
    }

    public function displayLabel(): string
    {
        $label = "{$this->name} ({$this->code})";

        return $this->is_gst ? "{$label} - GST" : $label;
    }
}
