本文整理汇总了PHP中app\models\User::register方法的典型用法代码示例。如果您正苦于以下问题:PHP User::register方法的具体用法?PHP User::register怎么用?PHP User::register使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\User
的用法示例。
在下文中一共展示了User::register方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
/**
* Registers a new user account.
* @return bool
*/
public function register()
{
if (!$this->validate()) {
return false;
}
$this->user->setAttributes(['email' => $this->email, 'username' => $this->username, 'password' => $this->password, 'firstName' => $this->firstName, 'lastName' => $this->lastName]);
return $this->user->register();
}
示例2: register
public function register()
{
$user_obj = new User();
$data = Input::all();
$user_obj->register($data);
return redirect('login')->with("msg", "Data successfully inserted");
}
示例3: actionCreate
/**
* Creates a new Student model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$student = new Student();
$user = new User();
$person = new Person();
if (Yii::$app->request->post()) {
$params = Yii::$app->request->post();
$person->load($params);
$user->load($params);
$user->password_hash = Yii::$app->getSecurity()->generatePasswordHash($params['User']['password_hash']);
$student->load($params);
if ($person->validate() && $user->validate() && $student->validate()) {
$person->save(false);
$user->person_id = $person->id;
$user->register();
$student->user_id = $user->id;
$student->save();
Yii::$app->session->setFlash('success', 'Se envío un correo de confirmación. Por favor verifique su correo electrónico');
return $this->refresh();
} else {
Yii::$app->session->setFlash('danger', 'Ocurrió ff un error al guardar. Vuelve a intentar');
return $this->refresh();
}
} else {
return $this->render('create', ['student' => $student, 'user' => $user, 'person' => $person]);
}
}
示例4: receive
/**
* Receive the registration datas from register view
*/
public function receive()
{
if (User::register() === true) {
$_SESSION['login'] = true;
$this->redirectTo('posts/index');
} else {
$this->messages = User::$messages;
$this->render('users/register');
}
}
示例5: findOrCreate
/**
* @param $userData
* @param $type
* @return User
*/
public function findOrCreate($userData, $type)
{
$user = User::where('email', '=', $userData->email)->first();
if (!$user) {
// If the user tried to login with out an account, default to talent when creating the user.
if (is_null($type)) {
$type = 'talent';
}
$user = User::register($userData->email, $userData->email, Hash::make($userData->email), $type);
}
return $user;
}
示例6: actionRegistration
public function actionRegistration()
{
if (!\Yii::$app->user->isGuest) {
$this->redirect(\Yii::$app->user->getReturnUrl());
}
$model = new User();
if ($model->load(Yii::$app->request->post()) && $model->register()) {
return $this->goBack();
} else {
return $this->render('registration', ['model' => $model]);
}
}
示例7: actionRegister
public function actionRegister()
{
$model = new User();
$model->scenario('register');
if (App::$app->request->post()) {
if ($model->register(App::$app->request->post())) {
return $this->redirect(['login']);
} else {
$this->alert = ['danger' => App::$user->log->getErrors()[0]];
}
}
return $this->render('register', ['model' => $model]);
}
示例8: actionRegister
public function actionRegister()
{
$model = new User();
$profile = new Profile();
if ($model->load(Yii::$app->request->getBodyParams(), '') && $model->validate()) {
if ($model->validate()) {
$id = $model->register();
$profile->createProfile($id);
return ['success' => true];
}
} else {
return $model;
}
}
示例9: register_by_openid
private function register_by_openid($openid)
{
$qc = new QC();
$arr = $qc->get_user_info();
$gender = $arr["gender"];
$niker = $arr["nickname"];
$user = ['openid' => $openid, 'sid' => Session::getId(), 'last_ip' => Request::ip(), 'niker' => $niker, 'last_time' => time(), 'device' => Request::header('User-Agent'), 'gender' => $gender];
$user_id = User::register($user);
if (empty($user_id)) {
return redirect('v1/register_by_3_err');
}
$user['id'] = $user_id;
$this->set_cookie_by_user(new \bps\User($user));
return redirect('http://blog.' . env('DOMAIN'));
}
示例10: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$faker = Faker\Factory::create();
$tags = Tag::all();
$skills = Skill::all();
for ($i = 0; $i < 50; $i++) {
$user = User::register($faker->unique()->userName, $faker->unique()->email, bcrypt('password'), 'talent');
$this->userRepository->save($user);
$profileData = ['first_name' => $faker->firstName, 'last_name' => $faker->lastName, 'location' => $faker->city, 'describe' => $faker->numberBetween(1, count($skills) - 1), 'about' => $faker->sentence(), 'facebook' => $faker->userName, 'linked_in' => $faker->userName, 'twitter' => $faker->userName, 'meetup' => $faker->userName, 'published' => $faker->boolean()];
$userSkills = '';
foreach (range(1, rand(2, 4)) as $x) {
$id = rand(1, count($tags) - 1);
$userSkills .= $tags[$id]->name . ",";
}
$profileData['skills'] = $userSkills;
$this->dispatcher->dispatch(new UpdateProfile($user, $profileData));
}
}
示例11: actionRegistration
public function actionRegistration($role = '')
{
if (!\Yii::$app->user->isGuest) {
$this->redirect(\Yii::$app->user->getReturnUrl());
}
if ($role == '') {
return $this->render('registration');
}
$model = new User();
$role_model = new Company();
$model->role = User::ROLE_COMPANY;
if ($role != 'company') {
//Student registration
$role = 'student';
$role_model = new Student();
$model->role = User::ROLE_STUDENT;
}
if ($model->load(Yii::$app->request->post()) && $role_model->load(Yii::$app->request->post()) && $model->register()) {
if ($role == 'student') {
$role_model->idUser = $model->id;
if ($role_model->save()) {
return $this->render('registration_student_success', ['model' => $model]);
}
} else {
$role_model->idUser = $model->id;
//Upload logo
if (isset($_FILES['Company']) && $_FILES['Company']['name']['logo_path'] != "") {
if (!in_array($_FILES['Company']['type']['logo_path'], $this->image_array)) {
$role_model->addError('logo_path', 'Доступные расширения для файла: jpg, gif, png.');
} else {
$rnd = rand(0, 9999);
$uploadedFile = UploadedFile::getInstance($role_model, 'logo_path');
$fileName = 'files/' . $rnd . '_' . $uploadedFile->name;
$role_model->logo_path = $fileName;
$uploadedFile->saveAs($fileName);
}
}
if ($role_model->save()) {
return $this->render('registration_company_success', ['model' => $model]);
}
}
}
return $this->render('registration_' . $role, ['model' => $model, 'role_model' => $role_model]);
}
示例12: register
public function register(Request $request)
{
try {
$this->validate($request, ['email' => 'required|email|unique:users,email', 'password' => 'required', 'first_name' => 'required', 'last_name' => 'required', 'birth_date' => 'required|birth_date', 'country' => 'required|exists:countries,id', 'city' => 'required', 'gender' => 'required|regex:/^[MF]$/', 'address' => 'required', 'zipcode' => 'required|regex:/^[0-9]+$/']);
$data = $request->all();
$user = new User();
$user->register($data);
// Invio email
Mail::send('emails.registration', ['user' => $user], function ($message) use($request) {
/**
* @var \Illuminate\Mail\Message $message
*/
$message->from(Config::get('mail.from.address'), Config::get('mail.from.name'))->to($request->input('email'))->subject('Registration');
});
} catch (ValidationException $e) {
$errors = $e->getErrors();
return parent::response(['validation' => false, 'errors' => $errors]);
}
return parent::response(['success' => true]);
}
示例13: handleRegister
public function handleRegister(Request $request, UserRepository $users)
{
if (!$this->checkCaptcha($request)) {
return json(trans('auth.validation.captcha'), 1);
}
$this->validate($request, ['email' => 'required|email', 'password' => 'required|min:8|max:16', 'nickname' => 'required|nickname|max:255']);
if (!option('user_can_register')) {
return json(trans('auth.register.close'), 7);
}
// If amount of registered accounts of IP is more than allowed amounts,
// then reject the register.
if (User::where('ip', $request->ip())->count() < option('regs_per_ip')) {
// Register a new user.
// If the email is already registered,
// it will return a false value.
$user = User::register($request->input('email'), $request->input('password'), function ($user) use($request) {
$user->ip = $request->ip();
$user->score = option('user_initial_score');
$user->register_at = Utils::getTimeFormatted();
$user->last_sign_at = Utils::getTimeFormatted(time() - 86400);
$user->permission = User::NORMAL;
$user->nickname = $request->input('nickname');
});
if (!$user) {
return json(trans('auth.register.registered'), 5);
}
event(new Events\UserRegistered($user));
return json(['errno' => 0, 'msg' => trans('auth.register.success'), 'token' => $user->getToken()])->withCookie('uid', $user->uid, 60)->withCookie('token', $user->getToken(), 60);
} else {
return json(trans('auth.register.max', ['regs' => option('regs_per_ip')]), 7);
}
}
示例14: finish
public function finish(Request $request)
{
$this->validate($request, ['email' => 'required|email', 'password' => 'required|min:6|max:16|confirmed', 'site_name' => 'required']);
// create tables
Artisan::call('migrate', ['--force' => true]);
Option::set('site_name', $request->input('site_name'));
Option::set('site_url', url('/'));
// register super admin
$user = User::register($request->input('email'), $request->input('password'), function ($user) use($request) {
$user->ip = $request->ip();
$user->score = option('user_initial_score');
$user->register_at = Utils::getTimeFormatted();
$user->last_sign_at = Utils::getTimeFormatted(time() - 86400);
$user->permission = User::SUPER_ADMIN;
});
$this->createDirectories();
return view('setup.wizard.finish')->with(['email' => $request->input('email'), 'password' => $request->input('password')]);
}