/**
  * 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');
     $fullname = $file->getClientOriginalName();
     // Client file name, including the extension of the client
     $hashname = date('H.i.s') . '-' . md5($fullname);
     // Hash processed file name, including the real extension
     $normal_name = uploadImagesProcesser($file, $hashname, $this->destinationPath, 848, 566);
     $normal_name = uploadImagesProcesser($file, $hashname, $this->largeThumbnailsPath, 263, 486);
     $normal_name = uploadImagesProcesser($file, $hashname, $this->smallThumbnailsPath, 263, 390);
     $model = $this->model->find($id);
     $oldThumbnails = $model->thumbnails;
     if ($oldThumbnails != NULL) {
         destoryUploadImages($this->largeThumbnailsPath, $oldThumbnails);
         destoryUploadImages($this->smallThumbnailsPath, $oldThumbnails);
     }
     $model->thumbnails = $normal_name;
     $models = new TravelPictures();
     $models->filename = $normal_name;
     $models->travel_id = $id;
     $models->user_id = Auth::user()->id;
     if ($model->save() && $models->save()) {
         return Response::json('success', 200);
     } else {
         return Response::json('error', 400);
     }
 }
 /**
  * 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');
     $destinationPath = 'uploads/travel/';
     $ext = $file->guessClientExtension();
     // Get real extension according to mime type
     $fullname = $file->getClientOriginalName();
     // Client file name, including the extension of the client
     $hashname = date('H.i.s') . '-' . md5($fullname) . '.' . $ext;
     // Hash processed file name, including the real extension
     $picture = Image::make($file->getRealPath());
     // crop the best fitting ratio and resize image
     $picture->fit(1024, 683)->save(public_path($destinationPath . $hashname));
     $picture->fit(430, 645)->save(public_path('uploads/travel_small_thumbnails/' . $hashname));
     $picture->fit(585, 1086)->save(public_path('uploads/travel_large_thumbnails/' . $hashname));
     $model = $this->model->find($id);
     $oldThumbnails = $model->thumbnails;
     $model->thumbnails = $hashname;
     File::delete(public_path('uploads/travel_small_thumbnails/' . $oldThumbnails), public_path('uploads/travel_large_thumbnails/' . $oldThumbnails));
     $models = new TravelPictures();
     $models->filename = $hashname;
     $models->travel_id = $id;
     $models->user_id = Auth::user()->id;
     if ($model->save() && $models->save()) {
         return Response::json('success', 200);
     } else {
         return Response::json('error', 400);
     }
 }