/**
  * Save Attachment (update)
  */
 public function postSaveAttachment()
 {
     $input = Input::get();
     if (empty($input['id'])) {
         return Response::json(array('error' => array('message' => "Bad request. Error", 'type' => "InvalidParameters", 'code' => 100)), 400);
     }
     $attachment = Attachment::find($input['id']);
     if (!$attachment) {
         return Response::json(array('error' => array('message' => "Bad request. Error", 'type' => "InvalidParameters", 'code' => 100)), 400);
     }
     if (!$attachment->updateSafe($input)) {
         return Response::json(array('error' => array('message' => $attachment->errors, 'type' => "InvalidParameters", 'code' => 100)), 400);
     }
     return Response::json($attachment);
 }
Example #2
0
 public function attach_attachment($attachment_id)
 {
     $attachment = Attachment::find($attachment_id);
     if (!$attachment) {
         $this->errors[] = 'No such attachment';
         return false;
     }
     $this->featured_image()->save($attachment);
     return true;
 }