コード例 #1
0
ファイル: AdminUsersController.php プロジェクト: strikles/php
 public function postCreate()
 {
     $title = 'Users';
     $all_input = \Request::all();
     $create_rules = array('first_name' => 'required', 'last_name' => 'required', 'email' => 'required|email|unique:users', 'password' => 'required|min:3|confirmed', 'password_confirmation' => 'required|min:3');
     $validator = \Validator::make($all_input, $create_rules);
     if ($validator->passes()) {
         // create a new user
         $user = new \App\User();
         $user->save();
         // update with vals
         $user->update($all_input);
         // set name
         $user->name = $all_input['first_name'] . ' ' . $all_input['last_name'];
         // set pass hash
         $user->password = \Hash::make($all_input['password']);
         $user->photo = 'images\\icons\\default_user.png';
         // reset confirmation
         if (isset($all_input['confirmed'])) {
             $user->confirmed = 1;
             $user->confirmation_code = "";
         } else {
             $user->confirmed = 0;
         }
         $user->update();
         error_log('User ' . json_encode($all_input));
         return redirect("/admin/users/{$user->id}/update");
     } else {
         return redirect("/admin/users/create")->withErrors($validator);
     }
 }