<?php

namespace App\Classes\Modules\Companies\Services;

use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\Modules\Companies\DataTransferObjects\CompanyObject;
use App\Models\Company;

class CreatesCompany extends AbstractUpdateRecord
{

    /**
     * @param CompanyObject $object
     * @return \Illuminate\Database\Eloquent\Model|null
     * @throws \App\Classes\Exceptions\MalformedRequestException
     */
    public function execute(CompanyObject $object) {
        $model = new Company();
        $model->reference_no = $object->getReferenceNo();
        $model->name = $object->getName();
        $model->type = $object->getType();

        return $this->handler($model);

    }
}