<?php

namespace App\Classes\Modules\Companies\Services;


use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\Modules\Companies\DataTransferObjects\ModuleObject;

class CreatesCompanyModule extends AbstractUpdateRecord
{
    /**
     * @param ModuleObject $module
     * @return \Illuminate\Database\Eloquent\Model
     * @throws \App\Classes\Exceptions\MalformedRequestException
     */
    public function execute(ModuleObject $module){

        $model = $module->getCompany()->modules()->create(['module_type' => $module->getType()]);

        return $this->handler($model);

    }

}