<?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;
use App\Models\CompanyModule;

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

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