public function postDelete() { $id = Input::get('id'); $validator = Validator::make(array('id' => $id), $this->validate_id_arr); if ($validator->fails()) { // return Redirect::to('gcm-users') // ->with('msg', 'Invalid ID') // ->with('state', '-1'); return json_encode(array(false, "Invalid ID")); } $user = GCMUser::find($id); if (!$user) { return json_encode(array(false, "User isn't found")); } try { $user->delete(); // return Redirect::to('gcm-users') // ->with('msg', 'User deleted successfully'); return json_encode(array(true, "User deleted successfully")); } catch (Exception $e) { // return Redirect::to('gcm-users') // ->with('msg', 'Can\'t delete User') // ->with('state', '-1'); return json_encode(array(false, "Can\\'t delete User")); } }
public function init() { $this->send_option = Input::get('sendOption'); if ($this->send_option == 1) { //all $this->users = GCMUser::where('activated', '=', 1)->get(); $this->not_active_users_count = GCMUser::where('activated', '=', 0)->count(); if ($this->users) { $this->count = $this->users->count(); } else { $this->count = 0; } } elseif ($this->send_option == 2) { //user $id = Input::get('users'); $this->users = array(GCMUser::find($id)); if (GCMUser::find($id)) { $this->count = 1; } else { $this->count = 0; } } }