This commit is contained in:
Diatrex 2020-09-07 13:10:18 +03:00
parent 1111aefa15
commit aacd3fa83a
2 changed files with 71 additions and 68 deletions

View File

@ -292,7 +292,9 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
->inRandomOrder() ->inRandomOrder()
->first(); ->first();
if ($adv) {
$adv = $this->getLocationNames($adv); $adv = $this->getLocationNames($adv);
}
return $adv; return $adv;
} }

View File

@ -343,17 +343,14 @@ class AdvsController extends PublicController
{ {
$id = is_null($id) ? $seo : $id; $id = is_null($id) ? $seo : $id;
$categories = array(); $adv = $this->adv_repository->getListItemAdv($id);
$categories_id = array();
$isActiveComplaints = $this->adv_model->is_enabled('complaints');
$isCommentActive = $this->adv_model->is_enabled('comments');
if ($isActiveComplaints) { if ($adv) {
if ($this->adv_model->is_enabled('complaints')) {
$complaints = ComplaintsComplainTypesEntryModel::all(); $complaints = ComplaintsComplainTypesEntryModel::all();
} }
$adv = $this->adv_repository->getListItemAdv($id);
$recommended_advs = $this->adv_repository->getRecommendedAds($adv->id); $recommended_advs = $this->adv_repository->getRecommendedAds($adv->id);
foreach ($recommended_advs as $index => $ad) { foreach ($recommended_advs as $index => $ad) {
@ -361,6 +358,8 @@ class AdvsController extends PublicController
$recommended_advs[$index] = $this->adv_model->AddAdsDefaultCoverImage($ad); $recommended_advs[$index] = $this->adv_model->AddAdsDefaultCoverImage($ad);
} }
$categories = array();
$categories_id = array();
for ($i = 1; $i <= 10; $i++) { for ($i = 1; $i <= 10; $i++) {
$cat = "cat" . $i; $cat = "cat" . $i;
if ($adv->$cat != null) { if ($adv->$cat != null) {
@ -382,8 +381,7 @@ class AdvsController extends PublicController
//Cloudinary Module //Cloudinary Module
$adv->video_url = null; $adv->video_url = null;
$isActiveCloudinary = $this->adv_model->is_enabled('cloudinary'); if ($this->adv_model->is_enabled('cloudinary')) {
if ($isActiveCloudinary) {
$CloudinaryModel = new VideoModel(); $CloudinaryModel = new VideoModel();
$Cloudinary = $CloudinaryModel->getVideo($id); $Cloudinary = $CloudinaryModel->getVideo($id);
@ -395,7 +393,7 @@ class AdvsController extends PublicController
$options = $this->optionRepository->findAllBy('adv_id', $id); $options = $this->optionRepository->findAllBy('adv_id', $id);
if ($isCommentActive) { if ($this->adv_model->is_enabled('comments')) {
$CommentModel = new CommentModel(); $CommentModel = new CommentModel();
$comments = $CommentModel->getComments($adv->id)->get(); $comments = $CommentModel->getComments($adv->id)->get();
} }
@ -425,7 +423,10 @@ class AdvsController extends PublicController
} else { } else {
return back(); return back();
} }
} else {
$this->messages->error(trans('visiosoft.module.advs::message.ad_doesnt_exist'));
return redirect()->route('visiosoft.module.advs::list');
}
} }
public function preview($id) public function preview($id)