#1893 [dress-theme] GG Anasayfa Giydirme

This commit is contained in:
Diatrex 2020-08-13 12:20:22 +03:00
parent fba2ffed8f
commit dcb368b4fe
5 changed files with 40 additions and 15 deletions

View File

@ -5,6 +5,7 @@ use Anomaly\Streams\Platform\Addon\AddonCollection;
use Anomaly\Streams\Platform\Entry\EntryCriteria;
use Anomaly\Streams\Platform\Image\Image;
use Illuminate\Support\Facades\Auth;
use Visiosoft\AdvsModule\Adv\Contract\AdvRepositoryInterface;
use Visiosoft\RecentlyviewedadsModule\Recently\RecentlyModel;
use Visiosoft\SubscriptionsModule\User\UserModel;
@ -12,11 +13,17 @@ class AdvCriteria extends EntryCriteria
{
private $image;
private $advRepository;
public function __construct(SettingRepositoryInterface $repository, Image $image)
public function __construct(
SettingRepositoryInterface $repository,
Image $image,
AdvRepositoryInterface $advRepository
)
{
$this->settings = $repository;
$this->image = $image;
$this->advRepository = $advRepository;
}
public function getAdvsModel()
@ -79,20 +86,7 @@ class AdvCriteria extends EntryCriteria
public function findAdsByCategoryId($catId, $level = 1)
{
$advModel = new AdvModel();
$advs = AdvModel::query()
->whereDate('finish_at', '>=', date("Y-m-d H:i:s"))
->where('status', '=', 'approved')
->where('slug', '!=', '')
->where('cat' . $level, $catId)
->get();
$ads = $advModel->getLocationNames($advs);
foreach ($ads as $index => $ad) {
$ads[$index]->detail_url = $advModel->getAdvDetailLinkByModel($ad, 'list');
$ads[$index] = $advModel->AddAdsDefaultCoverImage($ad);
}
return $ads;
return $this->advRepository->getByCat($catId, $level);
}
public function getCurrentLocale()

View File

@ -405,6 +405,26 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
return $ads;
}
public function getByCat($catID, $level = 1)
{
$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();
$ads = $this->model->getLocationNames($advs);
foreach ($ads as $index => $ad) {
$ads[$index]->detail_url = $this->model->getAdvDetailLinkByModel($ad, 'list');
$ads[$index] = $this->model->AddAdsDefaultCoverImage($ad);
}
return $ads;
}
public function getCategoriesWithAdID($id)
{
$adv = $this->model->find($id);

View File

@ -32,6 +32,8 @@ interface AdvRepositoryInterface extends EntryRepositoryInterface
public function latestAds();
public function getByCat($catID, $level = 1);
public function getCategoriesWithAdID($id);
public function extendAds($allAds, $isAdmin = false);

View File

@ -216,6 +216,10 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
'as' => 'ajax::getAds',
'uses' => 'Visiosoft\AdvsModule\Http\Controller\AjaxController@getMyAds'
],
'ajax/get-advs-by-category/{categoryID}' => [
'as' => 'ajax::getAds',
'uses' => 'Visiosoft\AdvsModule\Http\Controller\AjaxController@getAdvsByCat'
],
'advs/extendAll/{isAdmin?}' => [
'as' => 'advs::extendAll',
'uses' => 'Visiosoft\AdvsModule\Http\Controller\AdvsController@extendAll',

View File

@ -85,4 +85,9 @@ class AjaxController extends PublicController
return response()->json(['success' => true, 'content' => $my_advs, 'title' => $page_title]);
}
public function getAdvsByCat($categoryID, AdvRepositoryInterface $advRepository)
{
return $advRepository->getByCat($categoryID);
}
}