This commit is contained in:
Diatrex 2020-09-30 11:55:44 +03:00
commit c4cd1b9888
4 changed files with 21 additions and 38 deletions

View File

@ -2,7 +2,7 @@
{% for adv in advs %}
<div class="col-md-12 mb-2 list-classified bg-light">
<a href="{{ adv.detail_url }}" class="text-dark">
<div class="row{% if adv.doping != null %} doping_type4 {% endif %}">
<div class="row{{ adv.doping_type ? ' doping_type' ~ adv.doping_type }}">
<div class="col-md-2 justify-content-center align-self-center text-center border-right border-white">
<img class="img-thumbnail lazy" src="{{ img('visiosoft.theme.base::images/no-image.png').url }}"
data-src="{{ adv.cover_photo }}" alt="{{ adv.name }}"

View File

@ -2,67 +2,41 @@
use Anomaly\FilesModule\File\Contract\FileRepositoryInterface;
use Anomaly\FilesModule\Folder\Contract\FolderRepositoryInterface;
use Anomaly\SettingsModule\Setting\Contract\SettingRepositoryInterface;
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;
use Visiosoft\CatsModule\Category\CategoryModel;
use Visiosoft\AdvsModule\Category\Contract\CategoryRepositoryInterface;
use Visiosoft\LocationModule\City\CityModel;
use Visiosoft\LocationModule\Country\CountryModel;
class AdvRepository extends EntryRepository implements AdvRepositoryInterface
{
/**
* The entry model.
*
* @var AdvModel
*/
protected $model;
/**
* @var FileRepositoryInterface
*/
private $fileRepository;
/**
* @var FolderRepositoryInterface
*/
private $folderRepository;
/**
* Create a new AdvRepository instance.
*
* @param AdvModel $model
*/
public function __construct(
AdvModel $model,
SettingRepositoryInterface $settings,
FileRepositoryInterface $fileRepository,
FolderRepositoryInterface $folderRepository
)
{
$this->model = $model;
$this->settings = $settings;
$this->fileRepository = $fileRepository;
$this->folderRepository = $folderRepository;
}
/**
* Resolve the advs.
*
* @return AdvsInterface|null
*/
public function findById($id)
{
return $this->model->orderBy('created_at', 'DESC')->where('advs_advs.id', $id)->first();
}
public function searchAdvs($type, $param = null, $customParameters = null, $limit = null, $category = null, $city = null)
public function searchAdvs(
$type, $param = null, $customParameters = null,
$limit = null, $category = null, $city = null, $paginate = true
)
{
$isActiveDopings = new AdvModel();
$isActiveDopings = $isActiveDopings->is_enabled('dopings');
@ -239,7 +213,7 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
}
if ($type == "list") {
return $query->paginate($this->settings->value('streams::per_page'));
return $paginate ? $query->paginate(setting_value('streams::per_page')) : $query;
} else {
return $query->get();
}

View File

@ -6,7 +6,10 @@ interface AdvRepositoryInterface extends EntryRepositoryInterface
{
public function findById($id);
public function searchAdvs($type, $param = null, $customParameters = null, $limit = null, $category = null, $city = null);
public function searchAdvs(
$type, $param = null, $customParameters = null,
$limit = null, $category = null, $city = null, $paginate = true
);
public function softDeleteAdv($id);

View File

@ -232,7 +232,17 @@ class AdvsController extends PublicController
}
$isActiveCustomFields = $this->adv_model->is_enabled('customfields');
$advs = $this->adv_repository->searchAdvs('list', $param, $customParameters, null, $categoryId, $cityId);
$advs = $this->adv_repository->searchAdvs(
'list', $param, $customParameters, null, $categoryId, $cityId, false
);
if ($isActiveDopings) {
$featuredAdvsQuery = clone $advs;
$advs = app('Visiosoft\DopingsModule\Http\Controller\DopingsController')
->listFeatures($featuredAdvsQuery)->union($advs);
}
$advs = $advs->paginate(setting_value('streams::per_page'));
$advs = $this->adv_repository->addAttributes($advs);
if ($advs->currentPage() > $advs->lastPage()) {
@ -244,10 +254,6 @@ class AdvsController extends PublicController
), 301);
}
if ($isActiveDopings and $param != null) {
$featured_advs = app('Visiosoft\DopingsModule\Http\Controller\DopingsController')->listFeatures($advs);
}
$seenList = null;
foreach ($advs as $index => $ad) {
$advs[$index]->detail_url = $this->adv_model->getAdvDetailLinkByModel($ad, 'list');