summaryrefslogtreecommitdiffstats
path: root/controllers/PhotosController.php
diff options
context:
space:
mode:
authorMichael Francis <edude03@gmail.com>2011-05-28 13:28:16 -0400
committerMichael Francis <edude03@gmail.com>2011-05-28 13:28:16 -0400
commit2389d66da849798f8d4ec5f10e3b07c11da49185 (patch)
treee22556d12982395b469a23420c662662e3e064cc /controllers/PhotosController.php
downloadotakuhub-2389d66da849798f8d4ec5f10e3b07c11da49185.tar.xz
Initial Commit
Diffstat (limited to 'controllers/PhotosController.php')
-rw-r--r--controllers/PhotosController.php41
1 files changed, 41 insertions, 0 deletions
diff --git a/controllers/PhotosController.php b/controllers/PhotosController.php
new file mode 100644
index 0000000..ea41234
--- /dev/null
+++ b/controllers/PhotosController.php
@@ -0,0 +1,41 @@
+<?php
+
+namespace app\controllers;
+
+use app\models\Photo;
+
+class PhotosController extends \lithium\action\Controller {
+
+ public function index() {
+ $photos = Photo::all();
+ return compact('photos');
+ }
+
+ public function view() {
+ $photo = Photo::first($this->request->id);
+ return compact('photo');
+ }
+
+ public function add() {
+ $photo = Photo::create();
+
+ if (($this->request->data) && $photo->save($this->request->data)) {
+ $this->redirect(array('Photos::view', 'id' => $photo->id));
+ }
+ return compact('photo');
+ }
+
+ public function edit() {
+ $photo = Photo::find($this->request->id);
+
+ if (!$photo) {
+ $this->redirect('Photos::index');
+ }
+ if (($this->request->data) && $photo->save($this->request->data)) {
+ $this->redirect(array('Photos::view', 'args' => array($photo->id)));
+ }
+ return compact('photo');
+ }
+}
+
+?> \ No newline at end of file