From 22844efd870342e396fcd392a996a64543697d08 Mon Sep 17 00:00:00 2001 From: alp Date: Fri, 1 Nov 2019 19:48:59 +0300 Subject: [PATCH] If city or country can't find it was giving error --- .../visiosoft/advs-module/src/Adv/AdvRepository.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php b/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php index d5f4cd950..abba3ffb0 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php +++ b/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php @@ -238,10 +238,12 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface { $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 $adv; }