本文整理汇总了PHP中app\models\User::updateUser方法的典型用法代码示例。如果您正苦于以下问题:PHP User::updateUser方法的具体用法?PHP User::updateUser怎么用?PHP User::updateUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\User
的用法示例。
在下文中一共展示了User::updateUser方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
public function update(UpdateUserRequest $request, $key)
{
if ($user = UserModel::updateUser($request->input(), $key)) {
$message = $this->getMessage('success', ['username' => $user->username, 'updated at' => $user->updated_at]);
} else {
$message = $this->getMessage('error', [Request::ERROR_DATABASE_USER_NOT_FOUND]);
}
return json_encode($message);
}
示例2: updateUser
public function updateUser()
{
$user_obj = new User();
$data = Input::all();
//print_r($data);
$validator = Validator::make(['file' => $data['file']], ['file' => 'required|image|mimes:jpeg,bmp,png']);
if ($validator->fails()) {
return redirect('profile')->withErrors($validator, 'msg');
} else {
echo $filename = Input::file('file')->getClientOriginalName();
Input::file('file')->move('public/assets/prifile_pic', $filename);
$user_obj->updateUser($data, $filename);
}
return redirect('profile')->with("msg", "Profile successfully updates..");
}
示例3: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Purchase $purchaseModel, History $historyModel, Product $productModel, User $userModel, Request $request)
{
if (isset($_POST['update_template'])) {
//pr($_POST);
if (isset($_POST['col']) and !empty($_POST['col'])) {
$fields = serialize($_POST['col']);
} else {
$fields = null;
}
if (!empty($_POST['name_template'])) {
$template_name = $_POST['name_template'];
} elseif (isset($_POST['selected_name_template']) and !empty($_POST['selected_name_template'])) {
$template_name = $_POST['selected_name_template'];
} else {
$template_name = 'По умолчанию';
}
$template_id = $userModel->checkTemplates($template_name, 'purchases');
if ($template_id != null) {
$res = array('fields' => $fields);
$userModel->updateTemplate($res, $template_id, 'purchases');
} else {
//добавляем шаблон
$res = array('type' => 'purchases', 'user_id' => Auth::User()->id, 'template' => $template_name, 'fields' => $fields);
$userModel->addTemplates($res, 'purchases');
}
Session::flash('message', GetMessages("SUCCESS_SETTINGS_SAVE"));
return redirect($_SERVER['HTTP_REFERER']);
}
if (isset($_POST['delete_template'])) {
$userModel->deleteTemplate($_POST['selected_name_template'], 'purchases');
Session::flash('message', GetMessages("SUCCESS_TEMPLATE_DELETE"));
return redirect($_SERVER['HTTP_REFERER']);
}
if (isset($_POST['select_template'])) {
$userModel->updateUser(Auth::User()->id, array('template_prod_id' => $_POST['selected_name_template']));
Session::flash('message', GetMessages("SUCCESS_SETTINGS_SAVE"));
return redirect($_SERVER['HTTP_REFERER']);
}
if (isset($_POST['search_button'])) {
//pr($_POST);
if (strlen($_POST['search_field']) > 0) {
return redirect()->route('purchase.search.index', ['string' => $_POST['search_field']]);
} else {
return redirect($_SERVER['HTTP_REFERER']);
}
}
if (isset($_POST['update_purchase'])) {
if (!right('EditProduct')) {
abort(404);
}
unset($_POST['update_purchase']);
unset($_POST['_token']);
//pr($_POST);
$res = array();
foreach ($_POST as $element) {
if (array_key_exists('check', $element)) {
unset($element['check']);
//sort
isset($element['sort']['new']) ? $element['sort']['new'] = intval($element['sort']['new']) : ($field['sort']['new'] = '');
if ($element['sort']['new'] != $element['sort']['old']) {
$res[$element['id']]['purchase.sort'] = $element['sort']['new'];
}
//flag
!isset($element['flag']['new']) ? $element['flag']['new'] = 0 : ($element['flag']['new'] = 1);
if ($element['flag']['new'] != $element['flag']['old']) {
$res[$element['id']]['products.flag'] = $element['flag']['new'];
}
//base_price
isset($element['base_price']['new']) ? $element['base_price']['new'] = toFloat($element['base_price']['new']) : ($field['base_price']['new'] = 0);
if ($element['base_price']['new'] != $element['base_price']['old']) {
$res[$element['id']]['base_price'] = $element['base_price']['new'];
}
//currency
if ($element['currency']['new'] != $element['currency']['old']) {
$res[$element['id']]['currency'] = $element['currency']['new'];
}
//raise
isset($element['raise']['new']) ? $element['raise']['new'] = toFloat($element['raise']['new']) : ($field['raise']['new'] = 0);
if ($element['raise']['new'] != $element['raise']['old']) {
$res[$element['id']]['raise'] = $element['raise']['new'];
}
//discount_price
isset($element['discount_price']['new']) ? $element['discount_price']['new'] = toFloat($element['discount_price']['new']) : ($field['discount_price']['new'] = 0);
if ($element['discount_price']['new'] != $element['discount_price']['old']) {
$res[$element['id']]['discount_price'] = $element['discount_price']['new'];
}
//discount_bulk
isset($element['discount_bulk']['new']) ? $element['discount_bulk']['new'] = toFloat($element['discount_bulk']['new']) : ($field['discount_bulk']['new'] = 0);
if ($element['discount_bulk']['new'] != $element['discount_bulk']['old']) {
$res[$element['id']]['discount_bulk'] = $element['discount_bulk']['new'];
}
//comment
if ($element['comment']['new'] != $element['comment']['old']) {
$res[$element['id']]['comment'] = trim($element['comment']['new']);
//.........这里部分代码省略.........
示例4: processCart
private function processCart()
{
if ($this->error === false) {
unset($this->user->approvedTerms, $this->user->approvedShipping);
$this->request->setSession('cart', false);
$this->request->setSession('user', $this->user);
$rewards = $this->getCartRewardIds();
new \App\Modules\Transaction\Controllers\Create($this->user->unique_id, $rewards, $this->user->shipping);
$mUser = new Models\User();
$mUser->updateUser($this->user->unique_id, ['credits' => $this->user->credits, 'shipping' => json_encode($this->user->shipping)]);
return true;
}
return false;
}
示例5: param
public function param($param, User $userModel)
{
switch ($param) {
case 'show_hide_prod':
$userModel->updateUser(Auth::User()->id, array('show_hide_prod' => 1));
break;
case 'no_show_hide_prod':
$userModel->updateUser(Auth::User()->id, array('show_hide_prod' => 0));
break;
case 'show_hide_purch':
$userModel->updateUser(Auth::User()->id, array('show_hide_purch' => 1));
break;
case 'no_show_hide_purch':
$userModel->updateUser(Auth::User()->id, array('show_hide_purch' => 0));
break;
default:
return redirect($_SERVER['HTTP_REFERER']);
}
return redirect($_SERVER['HTTP_REFERER']);
}
示例6: setRememberToken
{
return $this->remember_token;
}
public function setRememberToken($value)
{
$this->remember_token = $value;
}
public function getRememberTokenName()
{
return 'remember_token';
}
public function clearSession()
{
$keys = [RECENTLY_VIEWED, SESSION_USER_ACCOUNTS, SESSION_TIMEZONE, SESSION_DATE_FORMAT, SESSION_DATE_PICKER_FORMAT, SESSION_DATETIME_FORMAT, SESSION_CURRENCY, SESSION_LOCALE];
foreach ($keys as $key) {
Session::forget($key);
}
}
public static function updateUser($user)
{
if ($user->password != !$user->getOriginal('password')) {
$user->failed_logins = 0;
}
}
}
User::updating(function ($user) {
User::updateUser($user);
});
User::updated(function ($user) {
Event::fire(new UserSettingsChanged());
});
示例7: update
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(Request $request, $id, User $userModel, History $historyModel)
{
if (isset($_POST['edit_user'])) {
if (!right('EditUsers')) {
abort(404);
}
$validator = Validator::make(array('name' => $request->input('name'), 'family' => $request->input('family'), 'password' => $request->input('password')), array('name' => 'required|min:3|max:55', 'family' => 'required|min:3|max:55', 'password' => 'min:4|max:4'), array('required' => 'Поле :attribute обязательно для заполнения', 'min' => 'Поле :attribute должно быть не меньше 4 символов', 'max' => 'Поле :attribute слишком длинное'));
if ($validator->fails()) {
Session::flash('message', GetMessages("ERROR_FIELD_ADD_NEW_USER"));
return redirect()->route('user.create');
} else {
if (isset($_POST['right'])) {
$serialize_rights = serialize($_POST['right']);
} else {
$serialize_rights = null;
}
if (strlen($request->input('password')) == 4) {
$password = Hash::make($request->input('password'));
} else {
$password = $userModel->getPasswordFromUser($id);
}
$showName = $request->input('family') . ' ' . $request->input('name');
$dataUser = array('name' => $request->input('name'), 'family' => $request->input('family'), 'patronymic' => $request->input('patronymic'), 'showname' => $showName, 'position' => $request->input('position'), 'login' => $request->input('login'), 'password' => $password, 'rights' => $serialize_rights, 'updated_at' => date('Y-m-d H:i:s'), 'user_id' => Auth::User()->id);
$userModel->updateUser($id, $dataUser);
$historyModel->saveHistory('update_user', $showName);
Session::flash('message', GetMessages("SUCCESS_USER_UPDATING"));
return redirect()->route('user.edit', ['id' => $id]);
}
}
if (isset($_POST['status_user'])) {
if (!right('EditUsers')) {
abort(404);
}
$status = $request->input('status');
$userModel->updateUser($id, array('status' => $status, 'updated_at' => date('Y-m-d H:i:s'), 'user_id' => Auth::User()->id));
$historyModel->saveHistory('status_user', $id, $status);
Session::flash('message', GetMessages("SUCCESS_CHANGE_STATUS_USER"));
return redirect($_SERVER['HTTP_REFERER']);
}
}