本文整理汇总了PHP中app\models\User::update方法的典型用法代码示例。如果您正苦于以下问题:PHP User::update方法的具体用法?PHP User::update怎么用?PHP User::update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\User
的用法示例。
在下文中一共展示了User::update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: record
public function record()
{
$phraseId = $this->json('phrase_id');
$userId = $this->json('user_id');
$username = $this->json('username');
$milliseconds = $this->json('milliseconds', 0);
$wpm = $this->json('wpm', 0);
$nwpm = $this->json('nwpm', 0);
$errors = $this->json('errors', 0);
$color = $this->json('color', 'black');
$isMobile = $this->json('isMobile', false);
$isTablet = $this->json('isTablet', false);
$isDNQ = $this->json('isDNQ', false);
if (!$userId) {
// Generate UserId:
$username = User::generateUsername();
$userId = User::createNew(['username' => $username]);
} else {
// Update Username
User::update($userId, ['username' => $username]);
}
$statId = Stat::createNew(['phrase_id' => $phraseId, 'user_id' => $userId, 'milliseconds' => $milliseconds, 'wpm' => $wpm, 'nwpm' => $nwpm, 'errors' => $errors, 'color' => $color, 'isMobile' => $isMobile, 'isTablet' => $isTablet, 'isDNQ' => $isDNQ]);
$stats = Stat::findById($statId);
$transform = Stat::transform($stats, ['username' => $username]);
return $this->success($transform);
}
示例2: update
public function update(User $user, UserRequest $request)
{
$user->update($request->all());
$user->roles()->sync($request->input('roleList'));
Flash::success(trans('general.updated_msg'));
return redirect(route('admin.users'));
}
示例3: updateUser
public function updateUser(User $user, UserRequest $request)
{
$input = $request->all();
// Remove empty inputs
$input = array_filter($input);
if ($input['type'] == 'user') {
$user->update($input);
} else {
if ($input['type'] == 'data') {
// Remove empty inputs
$input = array_filter($input);
// Create new row in user data if none exists
if (is_null($user->data)) {
$data = new UserData();
$data->user_id = $user->id;
$data->save();
$data->update($input);
} else {
$user->data->update($input);
}
}
}
$request->session()->flash('success', 'The user was updated.');
return redirect('/');
}
示例4: handle
/**
* Execute the job.
* @return String
* @internal param Role $role
*/
public function handle()
{
$this->user->update($this->data->except('newsletter')->toArray());
$this->user->setAttribute('newsletter', filter_var($this->data->get('newsletter', false), FILTER_VALIDATE_BOOLEAN));
foreach ($this->association as $key => $value) {
if ($value != '') {
if ($key == 'role_id') {
$this->user->roles()->sync(array($value));
} else {
$this->user->setAttribute($key, $value);
}
}
}
$this->user->save();
event(new UserWasUpdated($this->user));
return $this->user;
}
示例5: update
/**
* Update a user.
*
* @param UserUpdateRequest $request
* @param User $user
*
* @return \Illuminate\Http\JsonResponse
*/
public function update(UserUpdateRequest $request, User $user)
{
$data = $request->only('name', 'email');
if ($password = $request->input('password')) {
$data['password'] = Hash::make($password);
}
return response()->json($user->update($data));
}
示例6: updateAccountData
/**
* Allows a user to update all their account data at once
*
* @param $new_data
*
* @return bool|int|mixed
*/
public function updateAccountData($new_data)
{
// dob
if (array_has($new_data, 'dob')) {
// sometimes the date gets inserted as 000, so this function call fixes that
$data['dob'] = $this->correctDateFormat($new_data['dob']);
}
$this->dataResult = $this->user->update($new_data);
return $this->dataResult;
}
示例7: attach
/**
* Прикрепяет профиль фейсбука к профилю сайта
*
* @param array $attributes
* @param \app\models\User $userIdentity
*/
public function attach($attributes, $userIdentity)
{
\Yii::info(\yii\helpers\VarDumper::dumpAsString([$attributes, $userIdentity]), 'gs\\user');
$fields = ['fb_id' => $attributes['id'], 'fb_link' => $attributes['link']];
if ($userIdentity->getEmail() == '') {
$fields['email'] = $attributes['email'];
$fields['is_confirm'] = 1;
}
$userIdentity->update($fields);
if (!$userIdentity->hasAvatar()) {
$userIdentity->setAvatarFromUrl('https://graph.facebook.com/' . $attributes['id'] . '/picture?type=large', 'jpg');
}
}
示例8: make
public static function make($node_id, User $user, $type_id, $time, $amount)
{
$user->account += (double) $amount;
if ($user->update(false, ['account'])) {
$income = new static(['node_id' => $node_id, 'user_name' => $user->name, 'type_id' => $type_id, 'time' => $time]);
if ($income->save()) {
return $income;
} else {
throw new Exception(json_encode($income->getErrors(), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
}
} else {
throw new Exception(json_encode(func_get_args()));
}
}
示例9: post_user_edit
public function post_user_edit(Requests\EditUserRequest $request, User $user)
{
$user->update($request->except('username'));
return \back()->with('success', 'User has been updated successfully!');
}
示例10: set_settings
public function set_settings()
{
try {
$user = new User();
$user->id = auth()->user()->id;
$user->first_name = Request::input('first_name');
$user->last_name = Request::input('last_name');
$user->email = Request::input('email');
$user->street = Request::input('street');
$user->city = Request::input('city');
$user->state = Request::input('state');
$user->zip = Request::input('zip');
$user->update($user);
} catch (PDOException $e) {
die($e->getMessage());
}
}
示例11: update
function update()
{
$input = Request::all();
User::update($input);
return redirect("user/profile")->with("info", "Profile Updated!");
}
示例12: User
<?php
use App\Models\User;
require __DIR__ . '/autoload.php';
$user = new User();
$user->name = 'Alexandr';
$user->email = 'v@pupkin.ru';
$articles = $user::findAll();
foreach ($articles as $value) {
echo $value->name;
echo $value->email . '<br>';
}
$user->update(2);
示例13: update
/**
* Update user
*
* @param User $user
* @param array $data
*/
public static function update(User $user, $data = array())
{
$user->fill($data);
$user->update();
}
示例14: attach
/**
* @param array $attributes
* @param \app\models\User $userIdentity
*/
public function attach($attributes, $userIdentity)
{
$userIdentity->update(['vk_id' => $attributes['uid'], 'vk_link' => $attributes['screen_name']]);
if (!$userIdentity->hasAvatar()) {
$userIdentity->setAvatarFromUrl($attributes['photo_200']);
}
}
示例15: handle
public function handle(updateUserJob $Job)
{
$Updateusers = User::update(['username' => $Job->username, 'password' => $Job->password, 'email' => $Job->email]);
return $Updateusers;
}