Language

Languages that your application supported

Table name: languages

Description: Set up a list of supported languages for your applications.

By default: only English is activated.

Model

use SaasReady\Models\Language;

findByCode

Quickly retrieve the Language instance by using LanguageCode

use SaasReady\Constants\LanguageCode;

Language::findByCode(LanguageCode::ENGLISH);
Language::findByCode(LanguageCode::tryFrom('VI'));

The LanguageCode Enum

Contains every LanguageCode around the world.

use SaasReady\Constants\LanguageCode;

Response Entity

type Language = {
    uuid: string;
    code: string;
    is_active: boolean;
    activated_at: string;
    created_at: string;
    updated_at: string;
    activated_at: string;
}

Endpoints

[GET] saas/languages

Get a list of Languages

Request payload:

{
    limit: int; // optional, if this limit is null or not exists, will return ALL
    page: int; 
    is_active: boolean; // set true to get the activated langs only (default false)
}

Response payload:

{
    data: Language[],
}

[GET] saas/languages/{languageUuid}

Get single Language

Response payload:

{
    data: Language,
}

[POST] saas/languages

Create a new Language

Request payload:

{
    code: string;
    name: string;
    is_active: boolean;
}

Response payload:

{
    uuid: string,
}

[PUT] saas/languages/{languageUuid}

Update an existing Language

Request payload:

{
    code: string;
    name: string;
    is_active: boolean;
}

Response payload:

{
    uuid: string,
}

[DELETE] saas/languages/{languageUuid}

Delete an existing Language (soft)

Response payload:

{}

Helper Commands

Activate a Language (v1.0.1+)

php artisan saas-ready:activate-entity language {langCode}

php artisan saas-ready:activate-entity language en

Deactivate a Language (v1.0.1+)

php artisan saas-ready:deactivate-entity language {langCode}

php artisan saas-ready:deactivate-entity language en-SG

Last updated