From 76b2c8b5ffd11439ddbad2f0033e595e52bb4c51 Mon Sep 17 00:00:00 2001 From: Muammer Top Date: Thu, 28 Oct 2021 15:51:34 +0300 Subject: [PATCH] #4803 fix --- .../visiosoft/advs-module/src/Adv/AdvModel.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php b/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php index 8008e1b2d..e22271646 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php +++ b/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php @@ -288,10 +288,9 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface { foreach ($advs as $adv) { $locale = config('app.locale', config('streams::locales.default')); - - $country_id = $adv->country_id ?? 0; - $city_id = $adv->city ?? 0; - $district_id = $adv->district ?? 0; + $country_id = !empty($adv->country_id) ? $adv->country_id : 0; + $city_id = !empty($adv->city) ? $adv->city : 0; + $district_id = !empty($adv->district) ? $adv->district : 0; $q = collect(DB::select(" SELECT country.abv as country_abv, country_trans.name as country_name, @@ -301,8 +300,10 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface JOIN default_location_countries_translations AS country_trans on country.id = country_trans.entry_id WHERE country.id = " . $country_id . " and country_trans.locale = '" . $locale . "' "))->first(); - foreach ($q as $key => $value){ - $adv->setAttribute($key, $value); + if (is_object($q)) { + foreach ($q as $key => $value){ + $adv->setAttribute($key, $value); + } } } return $advs;