public function getRecommendation(Request $request)
 {
     $origin = $request->origin;
     $destination = $request->destination;
     $userbudget = $request->budget;
     // dd($origin,$destination);
     // $origin = "cebu city";
     // $destination = "manila";
     //get closest budget
     $budget = $this->getBudgetRecommendation($userbudget, $origin, $destination);
     if ($budget == 0) {
         // dd("in");
         $segments = $this->get_recommend($origin, $destination);
         // dd($segments);
         return response()->json($segments);
     } else {
         //get iterinaries that falls under the budget
         $iterinary_choices = Iterinary::whereRaw("price <= ?", [$budget])->where("origin", $origin)->where("destination", $destination)->lists("id");
         // dd($iterinary_choices);
         //get the iterinary_id that falls under the budget and is the best in terms of rating
         $suggested_iterinary = WeightedAverage::whereIn("ratingable_id", $iterinary_choices)->where("ratingable_type", "Iterinary")->max("average");
         $suggested_iterinary = WeightedAverage::where("average", $suggested_iterinary)->where("ratingable_type", "Iterinary")->lists("ratingable_id");
         //refers to points if there are iterinaries with the same rate
         // dd($suggested_iterinary);
         if (count($suggested_iterinary) > 1) {
             $suggested_iterinary = $this->getSuggestedIterinary($suggested_iterinary);
         }
         // dd($suggested_iterinary);
         $route_id = Iterinary::where("id", $suggested_iterinary)->lists("route_id");
         $segments = Segment::where("route_id", $route_id)->get();
         return response()->json($segments);
         // dd($segments);
         // dd($route_id);
         // dd($iterinary_choices);
     }
 }