Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Countries Laravel Package

drnd-dev/laravel-countries

View on GitHub
Deep Wiki
Context7

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()

::: code-group

use Lwwcas\LaravelCountries\Models\CountryRegion as Region;

Region::inRandomOrder()
    ->first()
    ->countries()
    ->get();

// Return a list of Country::class of a random CountryRegion::class
use Lwwcas\LaravelCountries\Models\CountryRegion as Region;

Region::whereSlug('americas')
    ->first()
    ->countries()
    ->get();

// Return a list of Country::class of a CountryRegion::class with Americas information
use Lwwcas\LaravelCountries\Models\CountryRegion as Region;

Region::whereSlug('americas')
    ->first()
    ->countries()
    ->whereSlug('brazil')
    ->first();

// Return Country::class with Brazil information
use Lwwcas\LaravelCountries\Models\CountryRegion as Region;

Region::whereSlug('americas')
    ->first()
    ->countries()
    # China is located in Asia
    ->whereSlug('china') // [!code warning]
    ->first();

// Return Null

:::

Where Slug

Returns the region matching the specified slug $slug.

->whereSlug(String $slug)
->orWhereSlug(String $slug)

::: code-group

use Lwwcas\LaravelCountries\Models\CountryRegion as Region;

Region::whereSlug('europe')->first();

// Return CountryRegion::class with Europe information
use Lwwcas\LaravelCountries\Models\CountryRegion as Region;

Region::whereSlug('americas')->orWhereSlug('europe')->get();

// Return a list of CountryRegion::class with Europe and Americas information
use Lwwcas\LaravelCountries\Models\CountryRegion as Region;

Region::whereSlug('EuRoPe')->first();

// Return CountryRegion::class with Europe information

:::

Where Name

Returns the region matching the specified name $name.

->whereName(String $name)
->orWhereName(String $name)

::: code-group

use Lwwcas\LaravelCountries\Models\CountryRegion as Region;

Region::whereName('Europe')->first();

// Return CountryRegion::class with Europe information
use Lwwcas\LaravelCountries\Models\CountryRegion as Region;

Region::whereName('Americas')->orwhereName('Europe')->get();

// Return a list of CountryRegion::class with Europe and Americas information
use Lwwcas\LaravelCountries\Models\CountryRegion as Region;

Region::whereName('EUROPE')->first();

// Return CountryRegion::class with Europe information

:::

Where 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)

::: code-group

use Lwwcas\LaravelCountries\Models\CountryRegion as Region;

Region::whereIso('EU')->first();

// Return CountryRegion::class with Europe information
use Lwwcas\LaravelCountries\Models\CountryRegion as Region;

Region::whereIso('AM')->orWhereIso('EU')->get();

// Return a list of CountryRegion::class with Europe and Americas information

:::

Where Iso Alpha 2

Returns the region matching the specified ISO alpha-2 code 'AM'.

->whereIsoAlpha2(String $alpha2)
->orWhereIsoAlpha2(String $alpha2)

::: code-group

use Lwwcas\LaravelCountries\Models\CountryRegion as Region;

Region::whereIsoAlpha2('EU')->first();

// Return CountryRegion::class with Europe information
use Lwwcas\LaravelCountries\Models\CountryRegion as Region;

Region::whereIsoAlpha2('AM')->orWhereIsoAlpha2('EU')->get();

// Return a list of CountryRegion::class with Europe and Americas information

:::

Where ICAO

Returns the region matching the specified ICAO code 'NAT'.

->whereICAO(String $icao)
->orWhereICAO(String $icao)

::: code-group

use Lwwcas\LaravelCountries\Models\CountryRegion as Region;

Region::whereICAO('EUR')->first();

// Return CountryRegion::class with Europe information
use Lwwcas\LaravelCountries\Models\CountryRegion as Region;

Region::whereICAO('NAT')->orWhereICAO('EUR')->get();

// Return a list of CountryRegion::class with Europe and Americas information

:::

Where IUCN

Returns the region matching the specified IUCN code 'Americas'.

->whereIUCN(String $iucn)
->orWhereIUCN(String $iucn)

::: code-group

use Lwwcas\LaravelCountries\Models\CountryRegion as Region;

Region::whereIUCN('Europe')->first();

// Return CountryRegion::class with Europe information
use Lwwcas\LaravelCountries\Models\CountryRegion as Region;

Region::whereIUCN('Americas')->orWhereIUCN('Europe')->get();

// Return a list of CountryRegion::class with Europe and Americas information

:::

Where TDWG

Returns the region matching the specified TDWG code 'NAM/SAM'.

->whereTDWG(String $tdwg)
->orwhereTDWG(String $tdwg)

::: code-group

use Lwwcas\LaravelCountries\Models\CountryRegion as Region;

Region::whereTDWG('EUR')->first();

// Return CountryRegion::class with Europe information
use Lwwcas\LaravelCountries\Models\CountryRegion as Region;

Region::whereTDWG('NAM/SAM')->orWhereTDWG('EUR')->get();

// Return a list of CountryRegion::class with Europe and Americas information

:::

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope