Merge pull request #757 from openclassify/dia

#2474 e-madencilik ads number bug
This commit is contained in:
Fatih Alp 2020-10-28 19:06:10 +03:00 committed by GitHub
commit 9492618ee1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 7 deletions

View File

@ -84,9 +84,14 @@ class AdvCriteria extends EntryCriteria
return $ads;
}
public function findAdsByCategoryId($catId, $level = 1)
public function findAdsByCategoryId($catId, $level = 1, $limit = 20)
{
return $this->advRepository->getByCat($catId, $level);
return $this->advRepository->getByCat($catId, $level, $limit);
}
public function countAdsByCategoryId($catId, $level = 1)
{
return $this->advRepository->countByCat($catId, $level);
}
public function getCurrentLocale()

View File

@ -4,6 +4,7 @@ use Anomaly\FilesModule\File\Contract\FileRepositoryInterface;
use Anomaly\FilesModule\Folder\Contract\FolderRepositoryInterface;
use Anomaly\Streams\Platform\Model\Advs\AdvsAdvsEntryModel;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
use Intervention\Image\Facades\Image;
use Visiosoft\AdvsModule\Adv\Contract\AdvRepositoryInterface;
use Anomaly\Streams\Platform\Entry\EntryRepository;
@ -377,15 +378,19 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
return $ads;
}
public function getByCat($catID, $level = 1)
public function getByCat($catID, $level = 1, $limit = 20)
{
$advs = $this->model
->whereDate('finish_at', '>=', date("Y-m-d H:i:s"))
->where('status', 'approved')
->where('slug', '!=', '')
->where('cat' . $level, $catID)
->limit(20)
->get();
->where('cat' . $level, $catID);
if ($limit) {
$advs = $advs->limit($limit);
}
$advs = $advs->get();
$ads = $this->model->getLocationNames($advs);
@ -397,6 +402,16 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
return $ads;
}
public function countByCat($catID, $level = 1)
{
return DB::table('advs_advs')
->whereDate('finish_at', '>=', date("Y-m-d H:i:s"))
->where('status', 'approved')
->where('slug', '!=', '')
->where('cat' . $level, $catID)
->count();
}
public function getCategoriesWithAdID($id)
{
$adv = $this->model->find($id);

View File

@ -35,7 +35,9 @@ interface AdvRepositoryInterface extends EntryRepositoryInterface
public function latestAds();
public function getByCat($catID, $level = 1);
public function getByCat($catID, $level = 1, $limit = 20);
public function countByCat($catID, $level = 1);
public function getCategoriesWithAdID($id);