Beispiel #1
0
 public function createAction()
 {
     F::$app->getUser()->accessDenied();
     if (F::$app->getRequest()->getIsPost()) {
         $item = new Item();
         $item->title = $_POST['title'];
         $item->description = $_POST['description'];
         $item->date_created = time();
         if ($item->save()) {
             F::$app->getResponse()->redirect(['items/index']);
         } else {
             return "Item was not added";
         }
     }
     return $this->render('create');
 }
 public function addItem($eventid, $name, $description, $pathtopic, $storeprice)
 {
     $item = new Item();
     $item->eventid = $eventid;
     $item->name = $name;
     $item->description = $description;
     $item->pathtopic = $pathtopic;
     $item->storeprice = $storeprice;
     //insert//
     $saved = $item->save();
     //verify insert//
     if ($saved) {
         $array = array('success' => true, 'item' => $item);
         return json_encode($array);
     } else {
         $array = array('success' => false, 'message' => 'Failed to add item');
         return json_encode($array);
     }
 }