本文整理汇总了PHP中app\User::save方法的典型用法代码示例。如果您正苦于以下问题:PHP User::save方法的具体用法?PHP User::save怎么用?PHP User::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\User
的用法示例。
在下文中一共展示了User::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLogin
public function getLogin()
{
if ($this->steam->validate()) {
$info = $this->steam->getUserInfo();
if (!is_null($info)) {
try {
$user = User::where('steamid', $info->getSteamID())->first();
if (is_null($user)) {
$user = new User();
$user->name = $info->getNick();
$user->steamid = $info->getSteamID();
$user->profileURL = $info->getProfileURL();
$user->save();
}
if ($user->name != $info->getNick() || $user->profileURL != $info->getProfileURL()) {
$user->name = $info->getNick();
$user->profileURL = $info->getProfileURL();
$user->save();
}
Auth::login($user);
return Redirect::to('/');
} catch (Illuminate\Database\Eloquent\ModelNotFoundException $ex) {
}
}
} else {
return $this->steam->redirect();
//redirect to steam login page
}
}
示例2: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->info('This command will create or update a user account.');
$this->info('Submit "cancel" as the value to cancel anytime.');
$email = $this->ask('Email address', '');
if ($email == 'cancel') {
$this->info('Cancelled.');
return;
}
$user = User::where('email', $email)->first();
if (is_null($user)) {
$this->info('A new user account will be created.');
$password = $this->secret('Choose a password');
if ($password == 'cancel') {
$this->info('Cancelled.');
return;
}
$user = new User();
$user->email = $email;
$user->password = bcrypt($password);
$user->save();
$this->info('New user created.');
} else {
$this->info('Entering edit mode for this account.');
$password = $this->secret('Choose a new password:');
$user->password = bcrypt($password);
$user->save();
$this->info('User updated.');
}
}
示例3: register
public function register(Request $request)
{
$farmChecking = $request->input("farmID");
$usernameCheck = $request->input("username");
$user = new User();
if (User::where("username", "=", $usernameCheck)->count() == 0) {
$user->name = $request->input("name");
$user->lastname = $request->input("lastname");
$user->username = $request->input("username");
$user->password = Hash::make($request->input("password"));
$user->email = $request->input("email");
$user->role = $request->input("role");
$user->phoneNumber = $request->input("phoneNumber");
if ($farmChecking != 0 || $farmChecking != null) {
$farmID = ($farmChecking - 320001) / 100;
if (Farm::find($farmID) != null) {
$farm = Farm::find($farmID);
$user->save();
$user->farm()->save($farm);
} else {
return response()->json(['error' => 'Wrong Farm ID'], 501);
}
} else {
$user->save();
}
} else {
return response()->json(['error' => 'duplicate username'], 502);
}
return $user::where("username", "=", $user->username)->first();
}
示例4: postUsers
public function postUsers(Request $request, User $user)
{
try {
$input = $request->input('user');
$email = $input['email'];
$password = $input['password'];
$confirm_password = $input['password_confirmation'];
$validator = \Validator::make(['email' => $email, 'password' => $password, 'confirm_password' => $confirm_password], ['email' => 'required|email|unique:users', 'password' => 'required', 'confirm_password' => 'required|same:password']);
if ($validator->fails()) {
return response()->json(['error' => $validator->messages()], 422);
// return response()->json((['error'=>'The email address has already been used.']), 422);
}
if ($password == $confirm_password) {
$user->email = $email;
$user->password = bcrypt($password);
$user->token_type = 'Bearer';
$user->role = 'user';
$user->save();
$hash = substr(bcrypt($user->password), 0, 20);
$user->access_token = $hash;
$user->save();
// $_POST['user_id'] = $user->id;
// $attribute = new AttributeController;
// $attr = $attribute->postInit();
$content = ['email' => $email, 'token_type' => $user->token_type, 'user_id' => $user->id, 'access_token' => $user->id . ':' . $user->access_token];
return response()->json($content, 200);
}
} catch (Exception $e) {
return response()->json(['error' => $e->getMessage()], 422);
}
}
示例5: postRegister
public function postRegister(RegisterRequest $request)
{
$this->user->name = $request->name;
$this->user->email = $request->email;
$this->user->password = bcrypt($request->password);
$this->user->save();
return redirect('auth/login');
}
示例6: postRegister
/**
* Handle a registration request for the application.
*
* @param RegisterRequest $request
* @return Response
*/
public function postRegister(RegisterRequest $request)
{
//code for registering a user goes here.
$this->user->email = $request->email;
$this->user->password = bcrypt($request->password);
$this->user->save();
$this->auth->login($this->user);
return redirect('/dash-board');
}
示例7: handle
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$this->user->email = $this->email;
$this->user->verified = false;
$this->user->save();
foreach ($this->user->emailChangeRequest() as $request) {
$request->token = null;
$request->save();
}
}
示例8: handle
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$password = Str::random(8);
$this->user->password = $password;
$this->user->save();
// Mail user
Mail::queue('auth.emails.reset', ["user" => $this->user, "password" => $password], function ($message) {
$message->to($this->user->email);
$message->subject('New password.');
});
}
示例9: postRegister
public function postRegister(RegisterRequest $request)
{
$this->auth->login($this->user);
$this->user->email = $request->email;
$this->user->username = $request->username;
$this->user->password = bcrypt($request->password);
$this->user->dept_name = $request->dept_name;
$this->user->user_type = $request->user_type;
$this->user->save();
return redirect('/auth/login');
}
示例10: postRegister
/**
* Handle a registration request for the application.
*
* @param RegisterRequest $request
* @return Response
*/
public function postRegister(RegisterRequest $request)
{
$this->user->nama = $request->nama;
$this->user->username = $request->username;
$this->user->password = bcrypt($request->password);
$this->user->jenisKelamin = $request->jenisKelamin;
$this->user->ttl = $request->ttl;
$this->user->alamat = $request->alamat;
$this->user->no_tlp = $request->no_tlp;
$this->user->save();
//code for registering a user goes here.
$this->auth->login($this->user);
return redirect('login');
}
示例11: handle
/**
* Execute the job.
*
* @return void
*/
public function handle(Facebook $fb)
{
try {
$response = $fb->get('/me?fields=' . implode($this->changedFields, ','), $this->user->token)->getGraphUser();
} catch (FacebookAuthenticationException $e) {
return false;
}
foreach ($response as $field => $value) {
if (in_array($field, $this->changedFields)) {
$this->user->{$field} = $value;
}
}
$this->user->save();
}
示例12: store
public function store(Registration_validate $request)
{
$request->all();
$User1 = new User(array('First_name' => $request->get('fn'), 'Last_name' => $request->get('ln'), 'Username' => $request->get('un'), 'password' => bcrypt($request->get('ps')), 'Mobile_number' => $request->get('mn')));
$User1->save();
return redirect('/Login');
}
示例13: create
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
protected function create(array $data)
{
$user = new User(['name' => $data['name'], 'email' => $data['email'], 'image' => $data['image'], 'password' => bcrypt($data['password'])]);
$user->role = 'user';
$user->save();
return $user;
}
示例14: update
/**
* Update the specified user in storage.
*
* @param User $user
* @param UserRequest $request
* @return Response
*/
public function update(User $user, UserRequest $request)
{
$data = $this->storeImage($request, 'picture');
$user->fill($data);
$user->save() == true ? Flash::success(trans('admin.update.success')) : Flash::error(trans('admin.update.fail'));
return redirect(route('admin.user.index'));
}
示例15: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(UserRequest $request)
{
$user = new User($request->except('password', 'password_confirmation'));
$user->password = bcrypt($request->password);
$user->confirmation_code = str_random(32);
$user->save();
}