Closed officialmmt closed 3 years ago
@officialmmt if you want World::getByCode
direct to city level, you have to pass country code first, e.g. World::getByCode('cn-11')
is Beijing, China
I am asking from start. How I can get City information with city code???
@officialmmt there is no way to get city information without country code, either you get a country model first and filter children()
or pass a country code with city code.
// get country model first
$country = World::getByCode('cm');
$country->children()->where('code','sou')->first();
=> Khsing\World\Models\City {#3224
id: 1049,
country_id: 1,
division_id: null,
name: "Sud-Oueste",
full_name: null,
code: "sou",
+local_name: "Sud-Oueste",
+local_full_name: null,
+local_alias: "Sud-Oueste",
+local_abbr: "Sud-Oueste",
}
// get city directly
$city = World::getByCode('cm-sou');
// or you can get through model
use Khsing\World\Models\City;
City::where('code','sou')->first();
Oh I didn't find that. Thank you for fast answers. Have a nice day!
World::getByCode('abd') not working with cities codes! I really need it. Can you fix it soon?