<?php

namespace App\Classes\Modules\Accounts\Services;

use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Classes\Modules\Accounts\DataTransferObjects\RegistrationObject;
use App\Models\User;

class CreatesUser extends AbstractUpdateRecord
{
    /**
     * @param RegistrationObject $object
     * @return \Illuminate\Database\Eloquent\Model
     * @throws \App\Classes\Exceptions\MalformedRequestException
     */
    public function execute(RegistrationObject $object) {
        $model = new User();
        $model->name = $object->getName();
        $model->email = $object->getEmail();
        $model->password = bcrypt($object->getPassword());
        $model->type = $object->getType();
        $model->status = $object->getStatus();

        return $this->handler($model);

    }
}