If city or country can't find it was giving error

This commit is contained in:
alp 2019-11-01 19:41:33 +03:00
parent bcf01c5b19
commit bece1c7a24

View File

@ -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;
}