public function store()
 {
     $content = file_get_contents('php://input');
     $this->validate_array = array('gcm_regid', 'name', 'email');
     $check_input = $this->validateInput($content, 'add');
     if (!$check_input[0]) {
         return $check_input[1];
     }
     $this->init($this->data);
     $check_exist = $this->user_obj->checkUserExistByRegID($this->gcm_regid);
     if ($check_exist) {
         return $this->getOutput(-200);
     }
     //        $check_exist2 = $this->user_obj->checkExistsByEmail($this->email);
     //        if ($check_exist2) {
     //            return $this->getOutput(-200);
     //        }
     $user = new GCMUser();
     $user->gcm_regid = $this->gcm_regid;
     $user->name = $this->name;
     $user->email = $this->email;
     $user->activated = 1;
     $user->created_at = $this->created_at;
     try {
         $user->save();
         return $this->getOutput(100);
     } catch (Exception $e) {
         return $this->getOutput(-105);
     }
 }
 public function postAdd()
 {
     $validator = Validator::make(Input::all(), $this->validator_user, $this->validate_user_messages);
     if ($validator->fails()) {
         return Redirect::back()->withInput()->withErrors($validator);
     }
     $check_exists = $this->user_obj->checkUserExistByRegID(Input::get('gcm_regid'));
     if ($check_exists) {
         return Redirect::back()->withInput()->with('msg', 'This register ID already exists')->with('state', '-1');
     }
     //        $check_exists2 = $this->user_obj->check_existsByEmail(Input::get('email'));
     //
     //        if ($check_exists2) {
     //            return Redirect::back()
     //                            ->withInput()
     //                            ->with('msg', 'This email already registered before')
     //                            ->with('state', '-1');
     //        }
     try {
         $user = new GCMUser();
         $user->gcm_regid = Input::get('gcm_regid');
         $user->name = Input::get('name');
         $user->email = Input::get('email');
         $user->activated = 1;
         $user->save();
         return Redirect::to('gcm-users')->with('msg', 'User added successfully');
     } catch (Exception $e) {
         return Redirect::back()->withInput()->with('msg', 'Failed to add user')->with('state', '-1');
     }
 }