From bece1c7a24ecf835807bc739f891ad1da6022c29 Mon Sep 17 00:00:00 2001 From: alp Date: Fri, 1 Nov 2019 19:41:33 +0300 Subject: [PATCH] If city or country can't find it was giving error --- .../default/visiosoft/advs-module/src/Adv/AdvModel.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php b/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php index 7a40a7665..eb9abab5d 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php +++ b/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php @@ -193,10 +193,13 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface $country = CountryModel::query()->where('location_countries.id', $adv->country_id)->first(); $city = CityModel::query()->where('location_cities.id', $adv->city)->first(); - $adv->setAttribute('country_name', $country->name); - $adv->setAttribute('city_name', $city->name); + if($country != null) { + $adv->setAttribute('country_name', $country->name); + } + if($city != null) { + $adv->setAttribute('city_name', $city->name); + } } - return $advs; }