Country

Countries around the world

Table name: countries

Description: For every SaaS product, countries would come in handy in case you want to deal with things internationally.

Possible use cases:

  • Register a new account (user or company), select a country

  • Tax resident

  • ...

Model

use SaasReady\Models\Country; 

findByCode

To quickly get a Country by using the Country's Code

use SaasReady\Constants\CountryCode;

$unitedStates = Country::findByCode(CountryCode::UNITED_STATES); // exact enum
$unitedStates = Country::findByCode(Country::tryFrom('US')); // string

The CountryCode Enum

Contains every CountryCode of all countries.

use SaasReady\Constants\CountryCode;

CountryCode::UNITED_STATES;
CountryCode::VIETNAM;

Response Entity

type Country = {
    uuid: string;
    code: string;
    name: string;
    continent: string;
    dial_code: string;
    created_at: string;
    updated_at: string;
}

Endpoints

[GET] saas/countries

Get a list of Countries

Request payload:

{
    limit: int; // optional, if this limit is null or not exists, will return ALL
    page: int; 
}

Response payload:

{
    data: Country[],
}

[GET] saas/countries/{countryUuid}

Get single Country

Response payload:

{
    data: Country,
}

[POST] saas/countries

Create a new Country

Request payload:

{
    code: string,
    name: string,
    continent: string,
    dial_code: string,
}

Response payload:

{
    uuid: string,
}

[PUT] saas/countries/{countryUuid}

Update an existing Country

Request payload:

{
    code: string,
    name: string,
    continent: string,
    dial_code: string,
}

Response payload:

{
    uuid: string,
}

[DELETE] saas/countries/{countryUuid}

Delete an existing Country (soft)

Response payload:

{}

Last updated