<?php

namespace App\Classes\Modules\Segments\Services;

use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\Modules\Segments\DataTransferObjects\ConstantObject;
use App\Models\SegmentConstant;

class UpdatesConstant extends AbstractUpdateRecord
{

    /**
     * @param SegmentConstant $model
     * @param ConstantObject $object
     * @return \Illuminate\Database\Eloquent\Model
     * @throws \App\Classes\Exceptions\MalformedRequestException
     */
    public function execute(SegmentConstant $model, ConstantObject $object)
    {
        $model->reference = $object->getReference();
        $model->value = json_encode($object->getValue());

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