/** * @param $data * @param bool $provider * @return static */ public function create($data, $provider = false) { /** * See if creating a user from a social account or the application */ if ($provider) { $user = User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => null, 'confirmation_code' => md5(uniqid(mt_rand(), true)), 'confirmed' => 1, 'status' => 1]); } else { $user = User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => $data['password'], 'confirmation_code' => md5(uniqid(mt_rand(), true)), 'confirmed' => config('access.users.confirm_email') ? 0 : 1, 'status' => 1]); } /** * Add the default site role to the new user */ $user->attachRole($this->role->getDefaultUserRole()); /** * If users have to confirm their email and this is not a social account, * send the confirmation email * * If this is a social account they are confirmed through the social provider by default */ if (config('access.users.confirm_email') && $provider === false) { $this->sendConfirmationEmail($user); } /** * Return the user object */ return $user; }
/** * @param $data * @param bool $provider * @return static */ public function create($data, $provider = false) { $user = User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => $provider ? null : $data['password'], 'confirmation_code' => md5(uniqid(mt_rand(), true)), 'confirmed' => config('access.users.confirm_email') ? 0 : 1]); $user->attachRole($this->role->getDefaultUserRole()); if (config('access.users.confirm_email')) { $this->sendConfirmationEmail($user); } return $user; }
/** * @param $data * @param bool $provider * @return static */ public function create($data, $provider = false) { if (empty($data['organization'])) { throw new GeneralException('You need to select one organization.'); } $org = $this->organization->findOrThrowException($data['organization']); $user = User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => $provider ? null : $data['password'], 'confirmation_code' => md5(uniqid(mt_rand(), true)), 'confirmed' => config('access.users.confirm_email') ? 0 : 1]); $user->organization()->associate($org); $user->role()->associate($this->role->getDefaultUserRole()); $user->save(); if (config('access.users.confirm_email')) { $this->sendConfirmationEmail($user); } return $user; }
/** * @param $data * @param bool $provider * @return static */ public function create($data, $provider = false) { /** * See if creating a user from a social account or the application */ $user = User::insertRecord($data); $user->detachPermissions([24, 25, 26]); if (array_key_exists('type_id', $data)) { switch ($data['type_id']) { case 1: $user->attachPermissions([24]); break; case 2: $user->attachPermissions([25]); break; case 3: $user->attachPermissions([26]); break; } } /*if ($provider) { $user = User::create([ 'name' => $data['name'], 'email' => $data['email'], 'password' => null, 'confirmation_code' => md5(uniqid(mt_rand(), true)), 'confirmed' => 1, 'status' => 1, ]); } else { $user = User::create([ 'name' => $data['name'], 'email' => $data['email'], 'password' => $data['password'], 'confirmation_code' => md5(uniqid(mt_rand(), true)), 'confirmed' => config('access.users.confirm_email') ? 0 : 1, 'status' => 1, ]); }*/ /** * Add the default site role to the new user */ $user->attachRole($this->role->getDefaultUserRole()); /** * If users have to confirm their email and this is not a social account, * send the confirmation email * * If this is a social account they are confirmed through the social provider by default */ if (config('access.users.confirm_email') && $provider === false) { $this->sendConfirmationEmail($user); } /** * Return the user object */ return $user; }