Merge pull request #1234 from openclassify/dia

#4908 emlak24 needs
This commit is contained in:
profstyle1 2021-11-22 16:14:31 +03:00 committed by GitHub
commit ec8e384410
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View File

@ -740,4 +740,21 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
->orderBy('distance')
->get();
}
public function getClassifiedsByCatsIDsAndLevels($categories, $limit = 10)
{
if (is_array($categories) && count($categories)) {
return $this->getModel()
->currentAds()
->where(function ($query) use ($categories) {
foreach ($categories as $level => $categoryID) {
$query->orWhereIn("cat$level", $categoryID);
}
})
->limit($limit)
->get();
}
return [];
}
}

View File

@ -76,4 +76,6 @@ interface AdvRepositoryInterface extends EntryRepositoryInterface
public function getNoImageClassifiedsReport();
public function getClassifiedsByCoordinates($lat, $lng, $distance = 50);
public function getClassifiedsByCatsIDsAndLevels($categories, $limit = 10);
}