Validate and create the user

@author Steve Montambeault
@link   http://stevemo.ca

@param array $data

@return \StdClass
489626
public function create(array $data)
    {
        try
        {
            if ( $this->validator->with($data)->passes() )
            {
                $this->users->create($data,$data['activate']);
                return true;
            }
        }
        catch (LoginRequiredException $e)
        {
            $this->validator->add('LoginRequiredException',$e->getMessage());
        }
        catch (PasswordRequiredException $e)
        {
            $this->validator->add('PasswordRequiredException',$e->getMessage());
        }
        catch (UserExistsException $e)
        {
            $this->validator->add('UserExistsException',$e->getMessage());
        }

        return false;
    }
850032
public function validator(array $data)
    {
        $validationRules = [
            'name'       => 'required|max:255',
            'first_name' => 'required',
            'last_name'  => 'required',
            'email'      => 'required|email|max:255|unique:user',
            'username'   => 'min:6|unique:user,username|regex:/^\S*$/u|nullable'
        ];

        $loginAttribute = strtolower(config('df.login_attribute', 'email'));
        if ($loginAttribute === 'username') {
            $validationRules['username'] = str_replace('|nullable', '|required', $validationRules['username']);
        }

        /** @var \DreamFactory\Core\User\Services\User $userService */
        $userService = ServiceManager::getService('user');
        if (empty($userService->openRegEmailServiceId)) {
            $validationRules['password'] = 'required|confirmed|min:6';
        }

        return Validator::make($data, $validationRules);
    }
210324
public function createUser($data) {
        $response=CodeBank_ClientAPI::responseBase();
        
        try {
            if(Member::get()->filter('Email', Convert::raw2sql($data->username))->count()>0) {
                $response['status']='EROR';
                $response['message']=_t('CodeBankAPI.EMAIL_EXISTS', '_An account with that email already exists');
                
                return $response;
            }
            
            
            //Create and write member
            $member=new Member();
            $member->FirstName=(!empty($data->firstname) ? $data->firstname:$data->username);
            $member->Surname=(!empty($data->surname) ? $data->surname:null);
            $member->Email=$data->username;
            $member->Password=$data->Password;
            $member->UseHeartbeat=0;
            
            if(!$member->validate()) {
                $response['status']='EROR';
                $response['message']=_t('CodeBankAPI.PASSWORD_NOT_VALID', '_Password is not valid');
                
                return $response;
            }
            
            $member->write();
            
            
            $response['status']='HELO';
            $response['message']="User added successfully";
        }catch (Exception $e) {
            $response['status']='EROR';
            $response['message']=_t('CodeBankAPI.SERVER_ERROR', '_Server error has occured, please try again later');
        }
        
        return $response;
    }
967383
public function create(array $data)
    {
        if (array_key_exists('password', $data)) {
            $data['password'] = bcrypt($data['password']);
        }

        return parent::create($data);
    }
1232709
public function createUser($data)
    {
        $data['type'] = 'user';
        $data['has-children'] = false;
        $principal = $this->principalUpdate($data);

        return (int) $principal->attributes()->{'principal-id'};
    }
646519
public function create(array $data)
    {
        $response = $this->ontraport->post(
            $this->getNamespace(), $this->toArray($data)
        );

        return $this->ontraport->item($this, $response);
    }
257355
public function create(array &$data = null) {
		$modelClass = $this->getModelClass();

		$model = $modelClass::factory($data);
		$model->setDatagate($this);

		if ($this->hasLocator()) {
			$model->setLocator($this->getLocator());
		}

		if (empty($data)) {
			$model->forceInsert();
		}

		return $model;
	}
1330376
public function create(array $data)
    {
        $user = User::create([
            'name'                  => $data['name'],
            'email'                 => $data['email'],
            'password'              => bcrypt($data['password']),
            'birthday_at'           => $data['birthday_at'],
            'locale'                => $data['locale'],
            'gender'                => $data['gender'],
            'city'                  => $data['city'],
            'about'                 => $data['about'],
            'profession'            => $data['profession'],
            'hobbies'               => $data['hobbies'],
            'homepage'              => $data['homepage'],
            'skype'                 => $data['skype'],
            'facebook'              => $data['facebook'],
            'twitter'               => $data['twitter'],
            'main_character'        => $data['main_character'],
            'main_guild'            => $data['main_guild'],
            'favorite_race'         => $data['favorite_race'],
            'favorite_spec'         => $data['favorite_spec'],
            'favorite_instance'     => $data['favorite_instance'],
            'favorite_battleground' => $data['favorite_battleground'],
        ]);

        return $user;
    }
1277269
public function find($username, array $data = [])
    {
        $response = $this->request->get(sprintf("users/%s", $username), $data);
        return new User($this->master, $response);
    }
843641
public static function createFromData(array $data): self
    {
        if (!isset($data['name'])) {
            throw new DomainException(self::REQUIRED_NAME);
        }

        switch ($data['name']) {
            case self::NAME_BLACKLIST:
                $action = new Actions\Blacklist($data);

                break;
            case self::NAME_CANCEL_SCHEDULED_PAYMENTS:
                $action = new Actions\CancelScheduledPayments($data);

                break;
            case self::NAME_GUESS_PAYMENT_CARD_EXPIRATION:
                $action = new Actions\GuessPaymentCardExpiration($data);

                break;
            case self::NAME_PICK_GATEWAY_ACCOUNT:
                $action = new Actions\PickGatewayAccount($data);

                break;
            case self::NAME_SCHEDULE_PAYMENT_RETRY:
                $action = new Actions\SchedulePaymentRetry($data);

                break;
            case self::NAME_SCHEDULE_PAYMENT:
                $action = new Actions\SchedulePayment($data);

                break;
            case self::NAME_SCHEDULE_INVOICE_RETRY:
                $action = new Actions\ScheduleInvoiceRetry($data);

                break;
            case self::NAME_SEND_EMAIL:
                $action = new Actions\SendEmail($data);

                break;
            case self::NAME_TRIGGER_WEBHOOK:
                $action = new Actions\TriggerWebhook($data);

                break;
            case self::NAME_STOP_SUBSCRIPTIONS:
                $action = new Actions\StopSubscriptions($data);

                break;
            case self::NAME_ADD_RISK_SCORE:
                $action = new Actions\AddRiskScore($data);

                break;
            case self::NAME_REQUEST_KYC:
                $action = new Actions\RequestKyc($data);

                break;
            case self::NAME_TAG_OR_UNTAG_CUSTOMER:
                $action = new Actions\TagOrUntagCustomer($data);

                break;
            default:
                throw new DomainException(
                    sprintf(self::UNEXPECTED_NAME, implode(', ', self::names()))
                );
        }

        return $action;
    }
733952
protected function validate(array $data = array())
    {
        $id = auth()->user()->id;
        if (empty($data)) {
            return false;
        }
        if ((int) array_get($data, 'secondary_user_id') !== $id) {
            return false;
        }

        $primary = array_get($data, 'primary_user_id');
        if ($primary === null) {
            return false;
        }
        return true;
    }
7448
public function instance($data)
    {
        $RagnarokUser = new SecUser();
        $this->userRagnarok = $RagnarokUser->populate($data);
        return $this->userRagnarok;
    }
307328
public static function createFromData(array $data)
    {
        if (!isset($data['method'])) {
            throw new DomainException(self::MSG_REQUIRED_METHOD);
        }

        switch ($data['method']) {
            case PaymentMethod::METHOD_ACH:
                $paymentInstrument = new AchInstrument($data);

                break;
            case PaymentMethod::METHOD_CASH:
                $paymentInstrument = new CashInstrument($data);

                break;
            case PaymentMethod::METHOD_PAYMENT_CARD:
                $paymentInstrument = new PaymentCardInstrument($data);

                break;
            case PaymentMethod::METHOD_PAYPAL:
                $paymentInstrument = new PayPalInstrument($data);

                break;
            default:
                throw new DomainException(
                    sprintf(self::MSG_UNSUPPORTED_METHOD, implode(',', self::$supportMethods))
                );
        }

        return $paymentInstrument;
    }
1256075
public function createUser(array $data)
    {
        $result = $this->httpRaw(self::WECHAT_USER_CREATE_PREFIX, $data, [
            'access_token' => $this->getAccessToken()
        ]);
        return isset($result['errcode']) && ($result['errcode'] ? $this->dump([$data,$result,$this->getAccessToken()]) : !$result['errcode']);
    }
887403
public static function createFromData(array $data)
    {
        if (!isset($data['method'])) {
            throw new DomainException('Method is required');
        }
        switch ($data['method']) {
            case PaymentMethod::METHOD_PAYMENT_CARD:
                $paymentInstrumentValidation = new PaymentCardValidation($data);

                break;
            default:
                throw new DomainException(
                    sprintf('Unexpected method. Only %s methods support', implode(',', self::$supportMethods))
                );
        }

        return $paymentInstrumentValidation;
    }
1009795
public function createUserFromOAuth($data)
    {
        $user = $this->createUser();
        $user->setAuthDataByProvider($data['provider'], ['id' => $data['id'], 'token' => $data['token']]);
        $user->setAuthProvider($data['provider']);
        $user->setFirstAuthProvider($data['provider']);
        $user->setUsername($data['email']);
        $user->setEmail($data['email']);
        $user->setPassword('none');
        $user->setEnabled(true);
        $user->setContact(new Contact);

        return $user;
    }
1314730
public function userCredentials(array $data = [])
    {

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

        $refreshCredentials = new OAuth2TokenBuilder();

        return $refreshCredentials->withClientId($data['clientId'])
            ->withClientSecret($data['clientSecret'])
            ->withRefreshToken($data['refreshToken'])
            ->build();
    }