<?php

namespace App\Models;

use App\Traits\HasCacheModel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class HCountry extends Model
{
    use HasFactory;
    use HasCacheModel;

    const PUBLIC_PATH = 'countries';

    public function __construct()
    {
        $this->table = 'h_country';
        $this->appends = ['flag'];
    }

    public function getFlagAttribute()
    {
        $code = $this->code;
        return asset(self::PUBLIC_PATH . "/$code.svg");
    }
}
