Below, you'll find a list of methods available in the Country model, along with friendly descriptions of what each method does. These methods are organized alphabetically for your convenience.
Sort countries by their name in either ascending or descending order.
->orderByName($sortMethod = 'asc')
Country::orderByName('asc')->get();
Find countries based on their area in square kilometers.
->whereAreaKm2()
Country::whereAreaKm2(500000)->get();
Filter countries by their Gross Domestic Product (GDP) in billions of USD.
->whereGdp()
Country::whereGdp(1000)->get();
Find countries by their GeoNames ID.
Use orWhereGeoname to add an OR condition to your query.
->whereGdp()
::: code-group
Country::whereGeoname(123456)->first();
Country::orWhereGeoname(789012)->first();
:::
Find countries by any ISO code (Alpha-2, Alpha-3, or Numeric).
Use orWhereIso to add an OR condition.
->whereIso()
::: code-group
Country::whereIso('US')->first();
Country::orWhereIso('840')->first();
Country::orWhereIso('840')
->orWhereIso('BR')
->orWhereIso('PTR')
->orWhereIso('USA')
->orWhereIso('US')
->orWhereIso('120')
->get();
:::
Find countries by their ISO Alpha-2 code. Use orWhereIsoAlpha2 to add an OR condition.
->whereIsoAlpha2()
::: code-group
Country::whereIsoAlpha2('FR')->first();
Country::orWhereIsoAlpha2('DE')->first();
:::
Find countries by their ISO Alpha-3 code. Use orWhereIsoAlpha3 to add an OR condition.
->whereIsoAlpha3()
::: code-group
Country::whereIsoAlpha3('FRA')->first();
Country::orWhereIsoAlpha3('DEU')->first();
:::
Find countries by their ISO Numeric code. Use orWhereIsoNumeric to add an OR condition.
->whereIsoNumeric()
::: code-group
Country::whereIsoNumeric('250')->first();
Country::orWhereIsoNumeric('276')->first();
:::
Find countries where a specific language is spoken.
->whereLanguage()
Country::whereLanguage('en')->get();
Find countries where all specified languages are spoken.
->whereLanguages()
Country::whereLanguages(['en', 'fr'])->get();
Find countries by their name. Use orWhereName to add an OR condition.
->whereName()
::: code-group
Country::whereName('France')->first();
Country::orWhereName('Germany')->first();
:::
Find countries where the name matches a pattern. Use orWhereNameLike to add an OR condition.
::: code-group
Country::whereNameLike('United')->get();
Country::orWhereNameLike('Kingdom')->get();
:::
Find countries by their official name. Use orWhereOfficialName to add an OR condition.
->whereOfficialName()
::: code-group
Country::whereOfficialName('Republic of India')->first();
Country::orWhereOfficialName('Commonwealth of Australia')->first();
:::
Find countries where the official name matches a pattern. Use orWhereOfficialNameLike to add an OR condition.
::: code-group
Country::whereOfficialNameLike('Republic')->get();
Country::orWhereOfficialNameLike('Kingdom')->get();
:::
Find countries by their international phone code. Use orWherePhoneCode to add an OR condition.
->wherePhoneCode()
::: code-group
Country::wherePhoneCode('+91')->first();
Country::orWherePhoneCode('+81')->first();
:::
Find countries with a specific population.
->wherePopulation()
Country::wherePopulation(100000000)->get();
Find countries by their slug (a URL-friendly name). Use orWhereSlug to add an OR condition.
->whereSlug()
::: code-group
Country::whereSlug('france')->first();
Country::orWhereSlug('germany')->first();
:::
Find countries by their unique identifier (UID). Use orWhereUid to add an OR condition.
->whereUid()
::: code-group
Country::whereUid('01ARZ3NDEKTSV4RRFFQ69G5FAV')->first();
Country::orWhereUid('01ARZ3NDEKTSV4RRFFQ69G5FAV')->first();
:::
Find countries by their WMO (World Meteorological Organization) code.
All three methods do the same thing.
->whereWmo()
->whereWmoCode()
->whereWorldMeteorologicalOrganizationCode()
::: code-group
Country::whereWmo('FR')->first();
Country::whereWmoCode('DE')->first();
Country::whereWorldMeteorologicalOrganizationCode('JP')->first();
:::
How can I help you explore Laravel packages today?