Exemple #1
0
 public function fire()
 {
     if (!Schema::hasTable('users')) {
         $this->error("Table users not exist");
         return;
     }
     $email = $this->argument("email");
     $password = $this->argument("password");
     $firstname = $this->option("firstname");
     $lastname = $this->option("lastname");
     $user = new AdminUser();
     $user->email = $email;
     $user->password = Hash::make($password);
     $user->first_name = $firstname;
     $user->last_name = $lastname;
     $user->is_administrator = $this->option("admintrator");
     if ($user->save()) {
         $this->info("Users is created");
     } else {
         $this->error("Can not seed user");
     }
 }
Exemple #2
0
 public function submitchange($id)
 {
     $user = AdminUser::findOrFail($id);
     $data = array("password" => Input::get("password"), "repassword" => Input::get("repassword"));
     $rules = array("password" => "required|min:6", "repassword" => "required|min:6|same:password");
     $validator = Validator::make($data, $rules);
     if ($validator->fails()) {
         return Redirect::route('admin.users.change')->withErrors($validator)->withInput();
     } else {
         $user->password = $data['password'];
         if ($user->save()) {
             Session::flash('success', "Đã cập nhật password user" . $user->email . " thành công");
             return Redirect::route('admin.users.change', $id);
         } else {
             Session::flash('error', "Xảy ra lỗi trong khi cập nhật password user " . $user->email);
             return Redirect::route('admin.users.change', $id);
         }
     }
 }