function showUpdateUser($id = 0)
 {
     $this->data['id'] = $id;
     //get list country
     $countryModel = new CountryBaseModel();
     $this->data['itemCountry'] = $countryModel->getAll();
     // WHEN UPDATE SHOW CURRENT INFOMATION
     if ($id != 0) {
         $item = User::select('users.*', 'groups.id as groups_id')->join('users_groups', 'users_groups.user_id', '=', 'users.id')->join('groups', 'groups.id', '=', 'users_groups.group_id')->where('users.id', $id)->first();
         //pr($item,1);
         if ($item) {
             $this->data['item'] = $item;
         } else {
             return Redirect::to($this->moduleURL . 'users-list');
         }
     }
     if (Request::isMethod('post')) {
         if ($this->postUpdateUser($id, $this->data)) {
             if ($id != 0) {
                 $messages = trans("backend::publisher/text.update_success");
                 $LastUrl = 'update/' . $id;
             } else {
                 $messages = trans("backend::publisher/text.insert_success");
                 $LastUrl = 'create';
             }
             Session::flash('mess', $messages);
             return Redirect::to($this->moduleURL . $LastUrl);
         }
     }
     $this->layout->content = View::make('manager_user.showUpdate', $this->data);
 }
 public function myProfile($idu = '')
 {
     $currentUser = $this->user;
     $this->data['item'] = $currentUser;
     $id = $currentUser->id;
     //get list country
     $countryModel = new CountryBaseModel();
     $this->data['itemCountry'] = $countryModel->getAll();
     if (Request::isMethod('post')) {
         // check validate
         $validate = Validator::make(Input::all(), User::getUpdateUserRules(), User::getUpdateUserLangs());
         $flag = $this->checkValidatePass($this->data);
         if ($validate->passes() && $flag == TRUE) {
             $username = Input::get('username');
             $password = Input::get('re-password');
             $firstName = Input::get('first_name');
             $lastName = Input::get('last_name');
             $email = Input::get('email');
             $address = Input::get('address');
             $country = Input::get('country');
             $phone = Input::get('phone');
             $contact_phone = Input::get('contact_phone');
             try {
                 $userData = Sentry::findUserById($id);
                 $userData->username = $username;
                 if ($password != "") {
                     $userData->password = $password;
                 }
                 $userData->email = $email;
                 $userData->first_name = $firstName;
                 $userData->last_name = $lastName;
                 $userData->address = $address;
                 $userData->country_id = $country;
                 $userData->phone = $phone;
                 $userData->phone_contact = $contact_phone;
                 if ($userData->save()) {
                     $data['id'] = $userData->id;
                     $messages = trans("backend::publisher/text.update_success");
                     Session::flash('mess', $messages);
                     if ($idu != 0) {
                         $url = Route('ToolAdvertiserManagerShowUpdate', $id);
                     } else {
                         $url = Route('ToolAdvertiserManagerProfile');
                     }
                     return Redirect::to($url);
                 }
             } catch (\Cartalyst\Sentry\Users\WrongPasswordException $e) {
                 $this->data['message'] = "Passwords do not exactly";
             }
         } else {
             $this->data['validate'] = $validate->messages();
         }
     }
     $this->layout->content = View::make('myProfile', $this->data);
 }