X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/ee06f37b0f6f6d94cd05a6ffae556660f7c4a2bc..c930e9176a5a85509c5b0230e2bff5c22a591432:/examples/restful/remote/app/controllers/users.php diff --git a/examples/restful/remote/app/controllers/users.php b/examples/restful/remote/app/controllers/users.php new file mode 100644 index 00000000..70851069 --- /dev/null +++ b/examples/restful/remote/app/controllers/users.php @@ -0,0 +1,62 @@ +success = true; + $res->message = "Loaded data"; + $res->data = User::all(); + return $res->to_json(); + } + /** + * create + */ + public function create() { + $res = new Response(); + $rec = User::create($this->params); + if ($rec) { + $res->success = true; + $res->message = "Created new User" . $rec->id; + $res->data = $rec->to_hash(); + } else { + $res->message = "Failed to create User"; + } + return $res->to_json(); + } + /** + * update + */ + public function update() { + $res = new Response(); + $rec = User::update($this->id, $this->params); + if ($rec) { + $res->data = $rec->to_hash(); + $res->success = true; + $res->message = 'Updated User ' . $this->id; + } else { + $res->message = "Failed to find that User"; + } + return $res->to_json(); + } + /** + * destroy + */ + public function destroy() { + $res = new Response(); + if (User::destroy($this->id)) { + $res->success = true; + $res->message = 'Destroyed User ' . $this->id; + } else { + $res->message = "Failed to destroy User"; + } + return $res->to_json(); + } +} +