Ejemplo n.º 1
0
 public function scan()
 {
     $user_id = Session::get('user_id');
     if (!Input::hasFile('file')) {
         return Response::json(array("result" => "No file"));
     }
     $result = "";
     $file = Input::file('file');
     $destinationPath = public_path() . "/uploads/";
     $file_name = date('YmdHis') . '_' . $file->getClientOriginalName();
     $uploadSuccess = $file->move($destinationPath, $file_name);
     if ($uploadSuccess) {
         $result = Wine::scan($destinationPath . $file_name);
         if ($result != -2) {
             $wine = Wine::where('wine_id', $result)->first();
             if ($wine != null) {
                 $input = $wine->toArray();
                 $rating = Rating::createNewRating($input);
             }
         }
     }
     return Response::json(array("result" => $result));
 }