Exemplo n.º 1
0
 /**
  * Creates a new portfolio
  */
 public function createAction()
 {
     if (!$this->request->isPost()) {
         return $this->dispatcher->forward(array("controller" => "portfolio", "action" => "index"));
     }
     $portfolio = new Portfolio();
     $portfolio->title = $this->request->getPost("title");
     $portfolio->short_description = $this->request->getPost("short_description");
     $portfolio->body = $this->request->getPost("body");
     $portfolio->image = $this->request->getPost("image");
     $portfolio->status = $this->request->getPost("status");
     if (!$portfolio->save()) {
         foreach ($portfolio->getMessages() as $message) {
             $this->flash->error($message);
         }
         return $this->dispatcher->forward(array("controller" => "portfolio", "action" => "new"));
     }
     $this->flash->success("portfolio was created successfully");
     return $this->dispatcher->forward(array("controller" => "portfolio", "action" => "index"));
 }