static function getRelatedTour(Tour $tour, $skip = 0, $take = 10) { if ($skip < 0) { throw new \Exception("Parameter 1 must be >= 0", 1); } if ($take < 1) { throw new \Exception("Parameter 2 must be > 0", 1); } if ($tour->_id) { foreach ($tour->tags as $tag) { $tags[$tag->type][] = $tag->tag; } //////////////////////////// // Related By Destination // //////////////////////////// foreach ($tags as $tag_type => $tag) { if ($tags[$tag_type]) { $related_tours[$tag_type] = Static::with('travel_agent'); switch ($tag_type) { case 'destination': $related_tours[$tag_type] = $related_tours[$tag_type]->TagDestination($tag); break; case 'poi': $related_tours[$tag_type] = $related_tours[$tag_type]->TagPoi($tag); break; case 'interest': $related_tours[$tag_type] = $related_tours[$tag_type]->TagInterest($tag); break; } $related_tours[$tag_type] = $related_tours[$tag_type]->TourScheduleBetween(\Carbon\Carbon::now(), \Carbon\Carbon::now()->addMonth(12))->where('_id', '!=', new \MongoId($tour->id))->skip($skip)->take($take)->get(); } } return $related_tours; } else { return []; } }