#503 fixed updated ad for deleted category

This commit is contained in:
vedatakd 2019-10-30 10:44:07 +03:00
parent 6b7af0233f
commit b28bc5c212
4 changed files with 35 additions and 20 deletions

View File

@ -22,4 +22,5 @@ return [
'cancelBtn' => "or Cancel", 'cancelBtn' => "or Cancel",
'link' => "", 'link' => "",
], ],
'update_category_info' => 'Please update category.',
]; ];

View File

@ -22,4 +22,5 @@ return [
'cancelBtn' => "ve ya İptal", 'cancelBtn' => "ve ya İptal",
'link' => "", 'link' => "",
], ],
'update_category_info' => 'Lütfen kategoriyi güncelleyiniz.',
]; ];

View File

@ -250,12 +250,17 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
$cat1 = CategoryModel::query()->where('cats_category.id', $adv->cat1)->first(); $cat1 = CategoryModel::query()->where('cats_category.id', $adv->cat1)->first();
$cat2 = CategoryModel::query()->where('cats_category.id', $adv->cat2)->first(); $cat2 = CategoryModel::query()->where('cats_category.id', $adv->cat2)->first();
if (!is_null($cat1))
$adv->setAttribute('cat1_name', $cat1->name); $adv->setAttribute('cat1_name', $cat1->name);
if ($cat2 == null) { else
$adv->setAttribute('cat2_name', ""); $adv->setAttribute('cat1_name', "");
} else {
if (!is_null($cat2))
$adv->setAttribute('cat2_name', $cat2->name); $adv->setAttribute('cat2_name', $cat2->name);
}
else
$adv->setAttribute('cat2_name', "");
return $adv; return $adv;
} }

View File

@ -257,12 +257,15 @@ class AdvsController extends PublicController
$cat = "cat" . $i; $cat = "cat" . $i;
if ($adv->$cat != null) { if ($adv->$cat != null) {
$item = $this->category_repository->getItem($adv->$cat); $item = $this->category_repository->getItem($adv->$cat);
if (!is_null($item)) {
$categories['cat' . $i] = [ $categories['cat' . $i] = [
'name' => $item->name, 'name' => $item->name,
'id' => $item->id 'id' => $item->id
]; ];
$categories_id[] = $item->id; $categories_id[] = $item->id;
} }
}
} }
if ($this->adv_model->is_enabled('customfields')) { if ($this->adv_model->is_enabled('customfields')) {
@ -681,8 +684,13 @@ class AdvsController extends PublicController
for ($i = 1; $i < 7; $i++) { for ($i = 1; $i < 7; $i++) {
if ($adv[$cat . $i] != null) { if ($adv[$cat . $i] != null) {
$name = $categoryRepository->getSingleCat($adv[$cat . $i]); $name = $categoryRepository->getSingleCat($adv[$cat . $i]);
if (!is_null($name)) {
$cats_d['cat' . $i] = $name->name; $cats_d['cat' . $i] = $name->name;
$cats['cat' . $i] = $name->id; $cats['cat' . $i] = $name->id;
} else {
$this->messages->info(trans('visiosoft.module.advs::message.update_category_info'));
}
} }
} }