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
Know your user's location better in order to serve them better
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:
[GET] saas/countries/{countryUuid}
Get single Country
Response payload:
[POST] saas/countries
Create a new Country
Request payload:
{
code: string,
name: string,
continent: string,
dial_code: string,
}
Response payload:
[PUT] saas/countries/{countryUuid}
Update an existing Country
Request payload:
{
code: string,
name: string,
continent: string,
dial_code: string,
}
Response payload:
[DELETE] saas/countries/{countryUuid}
Delete an existing Country (soft)
Response payload: