/**
  * Add item to gallery (insert)
  */
 public function postAddItem()
 {
     $input = Input::get();
     if (empty($input['gallery_id'])) {
         return Response::json(array('error' => array('message' => "Bad request. Error", 'type' => "InvalidParameters", 'code' => 100)), 400);
     }
     $gallery = Gallery::find($input['gallery_id']);
     if (!$gallery) {
         return Response::json(array('error' => array('message' => "Bad request. Error", 'type' => "InvalidParameters", 'code' => 100)), 400);
     }
     $result = $gallery->insertItem($input);
     if (!$result) {
         return Response::json(array('error' => array('message' => $gallery->errors, 'type' => "InvalidParameters", 'code' => 100)), 400);
     }
     return Response::json($result);
 }
Example #2
0
 public function attach_gallery($gallery_id)
 {
     $gallery = Gallery::find($gallery_id);
     if (!$gallery) {
         $this->errors[] = 'No such gallery';
         return false;
     }
     if ($this->galleries->contains($gallery_id)) {
         return true;
     }
     $this->galleries()->attach($gallery_id, array('type' => Gallery::POST_ITEM_TYPE));
     return true;
 }