Workflow
CountryRegion::class includes a variety of PHP functions. Many of these functions are used by the package itself; however, you are free to use them in your own applications if you find them convenient.
Available Methods
Here you can explore the available methods to manipulate Region information as you wish. These methods provide a convenient way to filter, retrieve, and modify regions and their associated data within your application.
| Method | Description |
|---|---|
| countries() | Returns a list of countries filtered by the region. |
| whereSlug('americas') | Returns the region matching the specified slug 'americas'. |
| whereName('Americas') | Returns the region matching the specified name 'Americas'. |
| whereIso('AM') | Returns the region matching the specified ISO code 'AM'. |
| whereIsoAlpha2('AM') | Returns the region matching the specified ISO alpha-2 code 'AM'. |
| whereICAO('NAT') | Returns the region matching the specified ICAO code 'NAT'. |
| whereIUCN('Americas') | Returns the region matching the specified IUCN code 'Americas'. |
| whereTDWG('NAM/SAM') | Returns the region matching the specified TDWG code 'NAM/SAM'. |
Method Listing
Countries
Returns a list of countries filtered by the region.
->countries()use Lwwcas\LaravelCountries\Models\CountryRegion as Region;
Region::inRandomOrder()
->first()
->countries()
->get();
// Return a list of Country::class of a random CountryRegion::classuse Lwwcas\LaravelCountries\Models\CountryRegion as Region;
Region::whereSlug('americas')
->first()
->countries()
->get();
// Return a list of Country::class of a CountryRegion::class with Americas informationuse Lwwcas\LaravelCountries\Models\CountryRegion as Region;
Region::whereSlug('americas')
->first()
->countries()
->whereSlug('brazil')
->first();
// Return Country::class with Brazil informationuse Lwwcas\LaravelCountries\Models\CountryRegion as Region;
Region::whereSlug('americas')
->first()
->countries()
# China is located in Asia
->whereSlug('china')
->first();
// Return NullWhere Slug
Returns the region matching the specified slug $slug.
->whereSlug(String $slug)->orWhereSlug(String $slug)use Lwwcas\LaravelCountries\Models\CountryRegion as Region;
Region::whereSlug('europe')->first();
// Return CountryRegion::class with Europe informationuse Lwwcas\LaravelCountries\Models\CountryRegion as Region;
Region::whereSlug('americas')->orWhereSlug('europe')->get();
// Return a list of CountryRegion::class with Europe and Americas informationuse Lwwcas\LaravelCountries\Models\CountryRegion as Region;
Region::whereSlug('EuRoPe')->first();
// Return CountryRegion::class with Europe informationWhere Name
Returns the region matching the specified name $name.
->whereName(String $name)->orWhereName(String $name)use Lwwcas\LaravelCountries\Models\CountryRegion as Region;
Region::whereName('Europe')->first();
// Return CountryRegion::class with Europe informationuse Lwwcas\LaravelCountries\Models\CountryRegion as Region;
Region::whereName('Americas')->orwhereName('Europe')->get();
// Return a list of CountryRegion::class with Europe and Americas informationuse Lwwcas\LaravelCountries\Models\CountryRegion as Region;
Region::whereName('EUROPE')->first();
// Return CountryRegion::class with Europe informationWhere Iso
Returns the region matching the specified ISO code 'AM'.
whereIso is just an alias for whereIsoAlpha2, so you can use either one interchangeably to get the same result.
->whereIso(String $iso)->orWhereIso(String $iso)use Lwwcas\LaravelCountries\Models\CountryRegion as Region;
Region::whereIso('EU')->first();
// Return CountryRegion::class with Europe informationuse Lwwcas\LaravelCountries\Models\CountryRegion as Region;
Region::whereIso('AM')->orWhereIso('EU')->get();
// Return a list of CountryRegion::class with Europe and Americas informationWhere Iso Alpha 2
Returns the region matching the specified ISO alpha-2 code 'AM'.
->whereIsoAlpha2(String $alpha2)->orWhereIsoAlpha2(String $alpha2)use Lwwcas\LaravelCountries\Models\CountryRegion as Region;
Region::whereIsoAlpha2('EU')->first();
// Return CountryRegion::class with Europe informationuse Lwwcas\LaravelCountries\Models\CountryRegion as Region;
Region::whereIsoAlpha2('AM')->orWhereIsoAlpha2('EU')->get();
// Return a list of CountryRegion::class with Europe and Americas informationWhere ICAO
Returns the region matching the specified ICAO code 'NAT'.
->whereICAO(String $icao)->orWhereICAO(String $icao)use Lwwcas\LaravelCountries\Models\CountryRegion as Region;
Region::whereICAO('EUR')->first();
// Return CountryRegion::class with Europe informationuse Lwwcas\LaravelCountries\Models\CountryRegion as Region;
Region::whereICAO('NAT')->orWhereICAO('EUR')->get();
// Return a list of CountryRegion::class with Europe and Americas informationWhere IUCN
Returns the region matching the specified IUCN code 'Americas'.
->whereIUCN(String $iucn)->orWhereIUCN(String $iucn)use Lwwcas\LaravelCountries\Models\CountryRegion as Region;
Region::whereIUCN('Europe')->first();
// Return CountryRegion::class with Europe informationuse Lwwcas\LaravelCountries\Models\CountryRegion as Region;
Region::whereIUCN('Americas')->orWhereIUCN('Europe')->get();
// Return a list of CountryRegion::class with Europe and Americas informationWhere TDWG
Returns the region matching the specified TDWG code 'NAM/SAM'.
->whereTDWG(String $tdwg)->orwhereTDWG(String $tdwg)use Lwwcas\LaravelCountries\Models\CountryRegion as Region;
Region::whereTDWG('EUR')->first();
// Return CountryRegion::class with Europe informationuse Lwwcas\LaravelCountries\Models\CountryRegion as Region;
Region::whereTDWG('NAM/SAM')->orWhereTDWG('EUR')->get();
// Return a list of CountryRegion::class with Europe and Americas information