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

This commit is contained in:
alp 2019-11-01 19:48:59 +03:00
parent bece1c7a24
commit 22844efd87

View File

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