/** * Action: Add resource images * @return Response */ public function postUpload($id) { $input = Input::all(); $rules = array('file' => 'image|max:3000'); $validation = Validator::make($input, $rules); if ($validation->fails()) { return Response::make($validation->errors->first(), 400); } $file = Input::file('file'); $normal_name = uploadImagesProcess($file, $this->destinationPath, 848, 556, 1696, 1132, $this->thumbnailsPath, 360, 214, 720, 428); $model = $this->model->find($id); $oldThumbnails = $model->thumbnails; if ($oldThumbnails != NULL) { destoryUploadImages($this->thumbnailsPath, $oldThumbnails); } $model->thumbnails = $normal_name; $models = new ProductPictures(); $models->filename = $normal_name; $models->product_id = $id; $models->user_id = Auth::user()->id; if ($model->save() && $models->save()) { return Response::json('success', 200); } else { return Response::json('error', 400); } }