<?php

namespace App\Classes\Modules\Currencies\Services;

use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
use App\Classes\Modules\Currencies\DataTransferObjects\CurrencyObject;
use App\Models\Country;
use App\Models\Currency;

class CreatesCurrency extends AbstractUpdateRelationshipRecord
{
    /**
     * @param Country $country
     * @param CurrencyObject $object
     * @return \Illuminate\Database\Eloquent\Model
     * @throws \App\Classes\Exceptions\MalformedRequestException
     */
    public function execute(Country $country, CurrencyObject $object) {

        $model = new Currency();
        $model->name = $object->getName();
        $model->short_code = $object->getShortCode();
        $model->symbol = $object->getSymbol();

        return $this->handler($country->currencies(), $model);

    }
}