To start using CountryGeographical::class, just add this to your code:
use Lwwcas\LaravelCountries\Models\CountryGeographical;
$geo = CountryGeographical::inRandomOrder()->first();
$geo->getGeoData();
The CountryGeographical data is designed to be seamlessly integrated with country-specific information.
use Lwwcas\LaravelCountries\Models\Country;
$country = Country::inRandomOrder()->first();
$geo = $country->geographical()->first();
$geoData = $geo->getGeoData();
or directly
use Lwwcas\LaravelCountries\Models\Country;
$country = Country::inRandomOrder()->first();
$geoData = $country->getGeoData();
In Laravel, you can easily include the geographical information of a country by leveraging the with() method when querying countries. This allows you to load the CountryGeographical data alongside the country model, providing access to region codes, time zones, and other geographical properties.
To retrieve a country along with its geographical data, simply use the following query:
$country = Country::with('geographical')->find($id);
How can I help you explore Laravel packages today?