Insert new user into database.

@param $data

@throws Exception

@return Model
760197
protected function createUserInstance($data)
    {
        $config = app('scaffold.config');

        if (!$model = $this->fetchModel($config)) {
            throw new Exception('Could not find a model to create user.');
        }

        try {
            $model::unguard();

            return (new $model())->create($this->dataWithId($data));
        } catch (Exception $e) {
            return (new $model())->create($data);
        }
    }
264442
public function createOne($data)
    {
        $row = $this->getTable()::create();

        $data = $this->filterData($data);

        $row->setFromArray($data);
        return $row->save();
    }
258164
public function create($data)
    {
        $uae = new AddUser($data);
        $uae = \Events::dispatch('on_before_user_add', $uae);
        if (!$uae->proceed()) {
            return false;
        }

        $config = $this->application->make('config');
        $hasher = new PasswordHash($config->get('concrete.user.password.hash_cost_log2'), $config->get('concrete.user.password.hash_portable'));

        if (isset($data['uIsValidated']) && $data['uIsValidated'] == 1) {
            $uIsValidated = 1;
        } elseif (isset($data['uIsValidated']) && $data['uIsValidated'] == 0) {
            $uIsValidated = 0;
        } else {
            $uIsValidated = -1;
        }

        if (isset($data['uIsFullRecord']) && $data['uIsFullRecord'] == 0) {
            $uIsFullRecord = 0;
        } else {
            $uIsFullRecord = 1;
        }

        $password_to_insert = isset($data['uPassword']) ? $data['uPassword'] : null;
        $hash = $hasher->HashPassword($password_to_insert);

        $uDefaultLanguage = null;
        if (isset($data['uDefaultLanguage']) && $data['uDefaultLanguage'] != '') {
            $uDefaultLanguage = $data['uDefaultLanguage'];
        }

        $entity = new UserEntity();
        $entity->setUserName($data['uName']);
        $entity->setUserEmail($data['uEmail']);
        $entity->setUserPassword($hash);
        $entity->setUserIsValidated($uIsValidated);
        $entity->setUserIsFullRecord($uIsFullRecord);
        $entity->setUserDefaultLanguage($uDefaultLanguage);
        $entity->setUserIsActive(true);

        $this->entityManager->persist($entity);
        $this->entityManager->flush();

        $newUID = $entity->getUserID();
        $ui = $this->userInfoRepository->getByID($newUID);

        if (is_object($ui)) {
            $uo = $ui->getUserObject();
            $groupControllers = \Group::getAutomatedOnRegisterGroupControllers($uo);
            foreach ($groupControllers as $ga) {
                if ($ga->check($uo)) {
                    $uo->enterGroup($ga->getGroupObject());
                }
            }

            // run any internal event we have for user add
            $ue = new UserInfoWithPassword($ui);
            $ue->setUserPassword($password_to_insert);
            \Events::dispatch('on_user_add', $ue);

            // Now we notify any relevant users.
            $type = $this->application->make('manager/notification/types')->driver('user_signup');
            /* @var UserSignupType $type */
            $u = new User();
            $createdBy = null;
            if (is_object($u)) {
                $creator = $u->getUserInfoObject();
                if (is_object($creator)) {
                    $createdBy = $creator->getEntityObject();
                }
            }
            $signup = new UserSignup($ui->getEntityObject(), $createdBy);
            $notifier = $type->getNotifier();
            $subscription = $type->getSubscription($signup);
            $notified = $notifier->getUsersToNotify($subscription, $signup);
            $notification = $type->createNotification($signup);
            $notifier->notify($notified, $notification);
        }

        return $ui;
    }
457537
public function insert($data = [])
	{
		$created = $this->model->insert($data);

		if( ! $created)
		{
			return new Payload(null, 'not_created');
		}

		return new Payload($created, 'created');
	}
763957
function insert($data)
    {
        $field = "";
        $values = "";

        foreach($data as $key => $value)
        {
            $value = $this->db->quote($value);
            $field = $field . "`$key`,";
            $values = $values . "'$value',";
        }

        $field = substr($field, 0, -1);
        $values = substr($values, 0, -1);
        return $this->db->query("insert into {$this->table} ($field) values($values)");
    }
152288
public function createNewRecord($data) {
        $people_email = new $this->model;

        $people_email['people_id']     = $data['people_id'];
        $people_email['email_id']      = $data['email_id'];

        if ($people_email->save()) {

            // Return the new ID
            return $people_email->id;
        }

        return false;
    }
193958
public function insert(array $data)
    {
        // validate email address
        if (!empty($data['email_address']) &&
                !filter_var($data['email_address'], FILTER_VALIDATE_EMAIL)) {
            throw new Exception(
                'Invalid value for field email_address'
            );
        }
        $project_id = empty($data['project_id']) ? 0 : $data['project_id'];
        $permissions = empty($data['permissions']) ? null :
                                                (array) $data['permissions'];
        unset($data['project_id'], $data['permissions']);
        $id = parent::insert($data);
        // add permission to project
        if ($project_id) {
            $permission = \TeamWorkPm\Factory::build('project/people');
            $permission->add($project_id, $id);
            if ($permissions) {
                $permissions['person_id']  = $id;
                $permissions['project_id'] = $project_id;
                $permission->update($permissions);
            }
        }

        return $id;
    }
1296036
protected function create(array $data)
    {
        return User::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => bcrypt($data['password']),
            'token' => $this->userRepository->createToken(),
            'active' => 1,
        ]);
    }
399398
public function insert($data)
	{
		//var_dump($data);
		unset($this->_error);
		if(is_array($data))
		{
			$fields = '';
			$values = '';
			reset($data);
			for($counter = 0, $maxIndex = count($data), $valid = true; $counter < $maxIndex && $valid == true; $counter ++)
			{
				$elementKey = key($data);
				$elementKey = $this->_db->escape($elementKey);
				$valid = in_array($elementKey, $this->_fields);
				if($valid == true)
				{
                    $element = $data[$elementKey];
                    $element = $this->_db->escape($element);
					if(is_object($element) == true)
					{
						$valid = false;
						$this->_error = 'field: '.$elementKey.'is an object (this method just accept strings)';
					}
					else
					{
						if(is_numeric($element) == false)
							$values .= '\''.$element.'\'';
						else
							$values .= $element;
						$fields .= $elementKey;
						if(($counter + 1) < $maxIndex)
						{
							$fields .= ',';
							$values .= ',';
						}
						next($data);
					}
				}
				else
				{
					$this->_error = 'field: '.$elementKey.' is not defined in '.$this->_tableName;
				}
			}
			if($valid == true)
			{
				$this->_query = 'INSERT INTO '.$this->_tableName.'('.$fields.') VALUES('.$values.')';
				if($this->_db->execute($this->_query) !== false)
				{
					return $this->_db->insertId();
				}
				else
				{
					$this->_error = $this->_db->errorStr();
				}
			}
		}
		return false;
	}
896387
public function me(array $data = [])
    {
        $response = $this->request->get("me", $data);
        return new User($this->master, $response);
    }
491839
public function updateData($data) {
		$Model = ClassRegistry::init($this->_authenticateObject->settings['userModel']);
		$Model->id = $this->_user[$Model->primaryKey];
		$userData = $Model->save($data, false);
		$this->_user = array_merge((array) $this->_user, $userData[$Model->alias]);
		$this->Auth->login($this->_user);
		return $userData;
	}
167597
public function insert(): self
    {
        /** @var self $data */
        $data = $this;

        if(!$this->validate("post", $missing))
        {
            throw new \Exception("[MVQN\REST\Endpoints\Endpoint] Annotations for the '".get_class($this)."' class require valid values be set ".
                "on all of the following properties before attempting an insert():\n> ".implode("\n> ", $missing)."\n");
        }

        /** @var self $endpoint */
        $endpoint = self::post($data);
        return $endpoint;
    }
865736
public function insertData($data)
    {

        try {
            $location1 = new Order();
            $location1->order_no = $data['order_no'];
            $location1->order_desc = $data['order_desc'];
            $location1->full_address = $data['full_address'];
            $location1->user_id = $data['user_id'];
            $location1->user_name = $data['user_name'];
            $location1->user_mobile = $data['user_mobile'];
            $location1->merchant_id = $data['merchant_id'];
            $location1->merchant_name = $data['merchant_name'];
            $location1->merchant_tel = $data['merchant_tel'];
            $location1->published_at = $data['published_at'];
            $location1->user_lat = $data['user_lat'];
            $location1->user_lng = $data['user_lng'];
            $location1->geom = new GeomPoint($data['user_lng'], $data['user_lat']);
            $location1->big_cat = isset($data['big_cat']) ? $data['big_cat'] : '';
            $location1->middle_cat = isset($data['middle_cat']) ? $data['middle_cat'] : '';
            $location1->small_cat = isset($data['small_cat']) ? $data['small_cat'] : '';
            $location1->order_type = isset($data['order_type']) ? $data['order_type'] :0;
            $location1->biz_type = isset($data['biz_type']) ? $data['biz_type'] : 0;
            $location1->save();
        } catch (\Exception $e) {
            Log::info('c=OrderApiRepository f=insertData  msg=' . $e->getMessage());
            return false;
        }
        return $location1->getQueueableId();

    }
981372
public function insert($data = null)
    {
        $currentIndex = $this->getFieldValue($this->getIndex());
        $fields = $this->getFields();
        $sql1 = '';
        $sql2 = '';
        $args = array();
        foreach ($fields as $field) {
            // if($this->getFieldValue($field, $data) !== NULL)
            if (in_array($field, $this->created_at_fileds)) {
                $this->{$field} = now();
            }
            $value = $this->getFieldValue($field, $data);
            $args[$field] = $value;
            $sql1 .= "`$field`, ";
            $sql2 .= ":$field, ";
        }
        if (!empty($sql1)) {
            $sql1 = substr($sql1, 0, -2);
            $sql2 = substr($sql2, 0, -2);
            if($currentIndex) {
                $this->db->removeCache($this->getCacheId($currentIndex));
            }
            return $this->db->insert('INSERT INTO `'.$this->table_name.'` ('.$sql1.') VALUES ('.$sql2.')', $args);
        }
        return false;
    }
546122
static public function add($data)
    {
        try {
            $model = new static;
            $attributes = array_flip($model->attributes);
            $data = array_filter($data, function ($data) use ($attributes) {
                return isset($attributes[$data]);
            }, ARRAY_FILTER_USE_KEY);
            $sql = 'INSERT INTO '.$model->table.' (';
            foreach ($data as $column => $value) {
                $sql .= '`'.$column.'`, ';
            }
            $sql = trim($sql, ', ');
            $sql .= ') VALUES (';
            foreach ($data as $column => $value) {
                $sql .= ':'.$column.', ';
            }
            $sql = trim($sql, ', ');
            $sql .= ')';
            $statement = $model->connect->prepare($sql);
            foreach ($data as $column => $value) {
                $statement->bindValue(':'.$column, $value);
            }
            try {
                $statement->execute();
                return $model->connect->lastInsertId();
            } catch(\PDOExecption $e) {
                $model->connect->rollback();
                return "Error" . $e->getMessage();
            }
        } catch( \PDOExecption $e ) {
            return "Error" . $e->getMessage();
        }
    }
1131829
public function add($data = [])
    {
        $insertId = $this->db->insert($data)->into($this->table)->execute(FALSE);

        return $insertId;
    }
160963
public function insert($data)
    {
        $row = $this->getTable()->insert($data);
        if (!$row instanceof IRow) {
            return $row;
        }

        if ($this->auditLogRepository) {
            $to = $this->filterValues($this->excludeColumns((array)$data));

            $data = [
                'version' => '1',
                'from' => [],
                'to' => $to,
            ];
            $this->pushAuditLog(AuditLogRepository::OPERATION_CREATE, $row->getSignature(), $data);
        }

        return $row;
    }