<?php

namespace App\Classes\Modules\Wallets\Services;

use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord;
use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
use App\Models\Wallet;
use App\Models\Company;

class CreatesWallet extends AbstractUpdateRelationshipRecord
{
    /**
     * @param WalletObject $object
     * @return \Illuminate\Database\Eloquent\Model
     * @throws \App\Classes\Exceptions\MalformedRequestException
     */
    public function execute(WalletObject $object, Company $company) {
        $model = new Wallet();
        //$model->company_id = $object->getCompanyId();
        $model->code = $object->getCode();
        $model->currency_id = $object->getCurrency();

        return $this->handler($company->wallets(), $model);
    }
}
