<?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
     * @throws \App\Classes\Exceptions\MalformedRequestException
     */
    public function execute(CompanyObject $object)
    {
        $model = new Company();
        $model->name = $object->getName();
        $model->reference = $object->getReference();
        $model->type = $object->getType();
        $model->status = $object->getStatus();

        return $this->handler($model);
    }
}
