#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

@ -167,19 +167,19 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
if (substr($para, 4, 3) === "cf_") { if (substr($para, 4, 3) === "cf_") {
$id = substr($para, 7); $id = substr($para, 7);
$minmax = substr($para, 0, 3); $minmax = substr($para, 0, 3);
if($minmax == 'min'){ if ($minmax == 'min') {
$num = $param[$minmax.'_cf_'.$id]; $num = $param[$minmax . '_cf_' . $id];
$int = (int)$num; $int = (int)$num;
$column = "JSON_EXTRACT(cf_json, '$.cf" . $id . "') >= '" . $int ."'"; $column = "JSON_EXTRACT(cf_json, '$.cf" . $id . "') >= '" . $int . "'";
$query = $query->whereRaw($column); $query = $query->whereRaw($column);
} }
if($minmax == 'max'){ if ($minmax == 'max') {
$num = $param[$minmax.'_cf_'.$id]; $num = $param[$minmax . '_cf_' . $id];
$int = (int)$num; $int = (int)$num;
$column = "JSON_EXTRACT(cf_json, '$.cf" . $id . "') <= '" . $int ."'"; $column = "JSON_EXTRACT(cf_json, '$.cf" . $id . "') <= '" . $int . "'";
$query = $query->whereRaw($column); $query = $query->whereRaw($column);
} }
@ -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();
$adv->setAttribute('cat1_name', $cat1->name); if (!is_null($cat1))
if ($cat2 == null) { $adv->setAttribute('cat1_name', $cat1->name);
$adv->setAttribute('cat2_name', ""); else
} else { $adv->setAttribute('cat1_name', "");
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,11 +257,14 @@ 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);
$categories['cat' . $i] = [ if (!is_null($item)) {
'name' => $item->name, $categories['cat' . $i] = [
'id' => $item->id 'name' => $item->name,
]; 'id' => $item->id
$categories_id[] = $item->id; ];
$categories_id[] = $item->id;
}
} }
} }
@ -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]);
$cats_d['cat' . $i] = $name->name; if (!is_null($name)) {
$cats['cat' . $i] = $name->id; $cats_d['cat' . $i] = $name->name;
$cats['cat' . $i] = $name->id;
} else {
$this->messages->info(trans('visiosoft.module.advs::message.update_category_info'));
}
} }
} }