<?php

namespace App\Traits;

use App\Models\Currency;

trait HasCurrency
{

    public function addCurrency(int $currency)
    {
        $this->currency()->sync(
            [$currency]
        );
    }

    public function currency()
    {
        return $this->morphToMany(Currency::class, 'currenciable');
    }

    public function getCurrencyAttribute()
    {
        return $this->currency()?->first();
    }
}
