当前位置: 首页>>代码示例>>PHP>>正文


PHP User::validate方法代码示例

本文整理汇总了PHP中app\User::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP User::validate方法的具体用法?PHP User::validate怎么用?PHP User::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\User的用法示例。


在下文中一共展示了User::validate方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: askNewPassword

 /**
  * Ask for new superuser password with confirmation
  *
  * @param  integer $attemps Max number of attemps
  *
  * @return bool
  */
 protected function askNewPassword($attemps = 3)
 {
     if ($attemps-- <= 0) {
         throw new Exception('Max number of attemps exceeded');
     }
     $this->superuser->password = $this->secret('Enter NEW superuser password: ');
     $this->superuser->password_confirmation = $this->secret('Enter NEW superuser password again: ');
     if ($this->superuser->validate()) {
         return true;
     }
     $this->showValidationErrors();
     return $this->askNewPassword($attemps);
 }
开发者ID:nerea91,项目名称:laravel,代码行数:20,代码来源:SetupSuperUserCommand.php

示例2: user

 /**
  * Log in check.
  * Password should be encrypted and validation should be done in the model.
  * Should use select to get the columns you are interested in.
  * 
  * @param Request
  */
 public function user(Request $request)
 {
     $name = $request->input('name');
     $password = $request->input('password');
     $user = User::validate($name, $password);
     if (!$user) {
         return redirect('/')->withErrors('Failed to validate user name or password');
     }
     $group = Group::getUserGroup($user);
     return redirect($group);
 }
开发者ID:KNein32,项目名称:KYYT1115,代码行数:18,代码来源:Login.php

示例3: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     // TODO: add check if current user is admin before he can add another admin
     $a = new User();
     if (!$a->validate(Input::all())) {
         return redirect('user/create')->withErrors($a->errors())->withInput();
     }
     $a->fill(Input::all());
     $a->save();
     $a->roles()->attach(Input::get('role'));
     Flash::success('New user is created');
     return Redirect::to('user');
 }
开发者ID:e11en,项目名称:laravel_basic,代码行数:19,代码来源:UserController.php

示例4: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $input = Request::all();
     $validation = User::validate($input);
     if ($validation->fails()) {
         $message = $validation->messages()->first();
         return Response()->json(ResponseManager::getError('', 10, $message));
     }
     $input['password'] = Hash::make($input['password']);
     $user = User::create($input);
     if ($user) {
         $message = 'Added Successfully.';
         return Response()->json(ResponseManager::getResult($user, 10, $message));
     } else {
         $message = 'Something went wrong. Please try again.';
         return Response()->json(ResponseManager::getError('', 10, $message));
     }
 }
开发者ID:maineventio,项目名称:newprojectbase,代码行数:23,代码来源:UserController.php

示例5: postIndex

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function postIndex(Request $request)
 {
     $usuario = new User();
     $inputs = $request->all();
     $usuario->fill($inputs);
     if ($usuario->validate()) {
         if ($usuario->save()) {
             $usersGroup = Sentinel::findRoleById(2);
             $user = Sentinel::findUserById($usuario->id);
             $usersGroup->users()->attach($user);
             $this->generarActivationReminder($user, 'activation');
             return redirect('login')->with('mensaje', 'Se registró el usuario correctamente');
         } else {
             return back()->withInput()->withErrors($usuario->getErrors());
         }
     } else {
         return back()->withInput()->withErrors($usuario->getErrors());
     }
 }
开发者ID:reysmerwvr,项目名称:jenion,代码行数:24,代码来源:RegistrationController.php

示例6: postSetting

 /**
  * Function setting account of user
  * @method POST
  * @author Tran Van Moi
  * @since  2015/05/20
  * @return response
  */
 public function postSetting()
 {
     $data = Input::all();
     $validator = User::validate($data, 'edit');
     if ($validator->fails()) {
         return redirect('user/setting')->withInput()->withErrors($validator);
     } else {
         if (Hash::check($data['current_password'], Auth::user()->password)) {
             $user = Auth::user();
             $user->name = $data['name'];
             $user->address = $data['address'];
             $user->birthday = $data['birthday'];
             if (Input::file('image')) {
                 $destination_path = './public/images/avatar/';
                 // upload path
                 $extension = Input::file('image')->getClientOriginalExtension();
                 // getting image extension
                 $file_name = str_random(8) . '.' . $extension;
                 // renameing image
                 if (Input::file('image')->move($destination_path, $file_name)) {
                     if ($user->image != "default.jpg" && File::exists($destination_path . $user->image)) {
                         File::delete($destination_path . $user->image);
                     }
                     $user->image = $file_name;
                 }
             }
             if ($data['password'] != "" && $data['password'] == $data['password_confirmation']) {
                 $user->password = Hash::make($data['password']);
             }
             $user->save();
             $url_image = LibraryPublic::get_url_image($user->image);
             Session::put('url_image_auth', $url_image);
             return redirect('user/setting')->withInput()->with('setting_status', ['status' => 'success', 'message' => 'Setting account is success!']);
         } else {
             return redirect('user/setting')->withInput()->with('setting_status', ['status' => 'danger', 'message' => 'Password is not correct']);
         }
     }
 }
开发者ID:ambarsetyawan,项目名称:laravel-1,代码行数:45,代码来源:UserController.php

示例7: postEdit

 /**
  * Admin edit user
  * @author  Tran Van Moi
  * @since  2015/06/01
  * @param  int $id
  * @return Response
  */
 public function postEdit($id = null)
 {
     $id = trim($id);
     $user = User::find($id);
     if ($user) {
         $data = Input::all();
         $data['id'] = $id;
         $validator = User::validate($data, 'admin-edit');
         if ($validator->fails()) {
             return Redirect::to('admin/user/edit/' . $id)->withInput()->withErrors($validator);
         } else {
             $user->name = $data['name'];
             $user->email = $data['email'];
             $user->birthday = $data['birthday'];
             $user->address = $data['address'];
             if (Input::file('image')) {
                 $destination_path = './public/images/avatar/';
                 // upload path
                 $extension = Input::file('image')->getClientOriginalExtension();
                 // getting image extension
                 $file_name = str_random(8) . '.' . $extension;
                 // renameing image
                 if (Input::file('image')->move($destination_path, $file_name)) {
                     if ($user->image != "default.jpg" && File::exists($destination_path . $user->image)) {
                         File::delete($destination_path . $user->image);
                     }
                     $user->image = $file_name;
                 }
             }
             if ($data['password'] != "") {
                 $user->password = Hash::make($data['password']);
             }
             $user->save();
             $url_image = LibraryPublic::get_url_image($user->image);
             Session::put('url_image_edit_user', $url_image);
             return redirect('admin/user/edit/' . $id)->withInput()->with('edit_status', ['status' => 'success', 'message' => 'Setting account is success!']);
         }
     } else {
         return redirect('admin/user/edit');
     }
 }
开发者ID:ambarsetyawan,项目名称:laravel-1,代码行数:48,代码来源:UserController.php

示例8: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, EditUserRequest $request)
 {
     $vld = User::validate($request->all(), $id);
     if (!$vld->passes()) {
         // dd($vld->errors()->getMessages());
         return Redirect::back()->with('messageNo', $vld->errors()->getMessages()['username'][0]);
     }
     $user = User::find($id);
     $password = '';
     if ($request->password != '') {
         $password = bcrypt($request->password);
     } else {
         $password = $user->password;
     }
     $employee = Employee::find($request->get('employee_id'));
     $user->update(['employee_id' => $request->get('employee_id'), 'fullname' => $employee->lastname . " " . $employee->firstname, 'username' => $request->username, 'password' => $password]);
     $user->attachGroup($request['group_id']);
     return redirect()->route('users.index')->with('messageOk', 'Update user successfully');
 }
开发者ID:phanngoc,项目名称:internal-tool,代码行数:25,代码来源:UserController.php


注:本文中的app\User::validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。