<?php

namespace App\Classes\Modules\Segments\Services;

use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\Modules\Segments\DataTransferObjects\SegmentObject;
use App\Models\Segment;

class CreatesSegment extends AbstractUpdateRecord
{

    /**
     * @param SegmentObject $object
     * @return \Illuminate\Database\Eloquent\Model
     * @throws \App\Classes\Exceptions\MalformedRequestException
     */
    public function execute(SegmentObject $object)
    {
        $model = new Segment();
        $model->name = $object->getName();
        $model->company_module_id = $object->getCompanyModuleId();

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