public function postEditProfile()
 {
     $editMessage = "";
     $imageFilePath = ImageController::uploadImage("avatar");
     $rules = array("full_name" => "required|min:3|max:32", "phone" => "numeric|min:11");
     if (Validator::make(Input::all(), $rules)->fails()) {
         $editMessage = "Validate false";
         Session::put("editMessage", $editMessage);
         return $editMessage;
     }
     $arrayUpdate = array('full_name' => Input::get("full_name"), 'phone' => Input::get("phone"), 'address' => Input::get("address"), 'avatar' => $imageFilePath);
     if ($this->model->updateUserInfor(Input::get("user_id"), $arrayUpdate)) {
         $userInfor = Users::getInformation(['param1' => 'user_id', 'param2' => Input::get("user_id")]);
         Session::put("user_info", $userInfor);
         return Redirect::to("member/edit-profile");
     } else {
         $editMessage = "Update database error!";
         Session::put("editMessage", $editMessage);
         return $editMessage;
     }
 }
Esempio n. 2
0
 /**
  *	Lay bai dang theo user
  *	@var string user_id
  *	@return array 2-D
  */
 public static function getUserPost($user_id)
 {
     $result = self::where("user_id", "=", $user_id)->get();
     if (isset($result)) {
         foreach ($result as $index => $item) {
             $temp = Users::getInformation(['param1' => 'user_id', 'param2' => $item['user_id']]);
             $item['user_id'] = $temp['full_name'];
             $temp = Category::getItemInfor($item['category_id']);
             $item['category_id'] = $temp['name'];
             $temp = Category_lv2::getItemInfor($item['category_id2']);
             $item['category_id2'] = $temp['name'];
         }
         return $result->toArray();
     } else {
         return null;
     }
 }
 public function loginSubmit()
 {
     $username = Input::get("user_input");
     $pass = md5(sha1(Input::get("password_login")));
     if ($username == ADMIN && ($pass = ADMIN_PASSWORD)) {
         Session::put("logined", "true");
         Session::put("admin", "true");
         return Redirect::to("user");
     }
     if (Users::checkLogin($username, $pass)) {
         Session::put("logined", "true");
         Session::put("email", Input::get("user_input"));
         $userInfor = Users::getInformation(['param1' => 'email', 'param2' => Input::get("user_input")]);
         Session::put("user_info", $userInfor);
         return Redirect::to("member/edit-profile");
     } else {
         return view("login")->with("error_message", "Ten dang nhap hoac mat khau khong dung");
     }
 }