diff --git a/controllers/PointController.php b/controllers/PointController.php index 123399d..1aae319 100644 --- a/controllers/PointController.php +++ b/controllers/PointController.php @@ -81,8 +81,13 @@ class PointController extends Controller } $photoLinksRes = implode('; ', array_keys($photoLinksRes)); + $categoryId = 0; + if (array_search($point->categoryId, Category::$paidIds) !== FALSE) { + $categoryId = $point->categoryId; + } + $similarPoints = Point::model()->getAll(array('where' => '`status` = "published" AND categoryId = ' . $point->categoryId . ' AND `id` <> ' . $point->id . ' ORDER BY RAND() LIMIT 6;')); - $closestPoints = Point::model()->getClosestPoints($pointId); + $closestPoints = Point::model()->getClosestPoints($pointId, $categoryId); $randomPoint = Point::model()->getRandom(); $randomPoint->description = mb_substr($randomPoint->description, 0, 400, 'UTF-8'); $randomPoint->description = Helper::replaceLinks($randomPoint->description); diff --git a/models/Point.php b/models/Point.php index 54f038b..6b6f0e6 100644 --- a/models/Point.php +++ b/models/Point.php @@ -47,7 +47,7 @@ class Point extends Model return $this->getByPK($pointId); } - public function getClosestPoints($pointId) + public function getClosestPoints($pointId, $categoryNot = 0) { $degrees = 1; @@ -64,6 +64,8 @@ class Point extends Model WHERE `status` = "published" AND + `categoryId` != ' . $categoryNot . ' + AND `lat` BETWEEN :minLat AND :maxLat AND `lng` BETWEEN :minLng AND :maxLng