trait Translations

Translations trait

Properties

protected string|null $currentLanguage Current language

Methods

static void
bootTranslations()

Boot trait.

string
getCurrentLanguage()

Get current language

string|null
translateAttribute(string $attribute, string|null $language = null)

Return translated value

bool
translateAttributes(string $language)

Translate attributes

array
getTranslatedAttributes()

Get translation attributes

string|null
getTranslationReferenceAttributeName()

Get translation refernce attribute name

string|null
getTranslationModelClass()

Get translation miodel class

Relation|null
translations()

HasMany relation

Builder
getTranslationsQuery(string|null $language = null)

Get translations query

Model|false
translation(string|null $language = null, bool $query = false)

Get translation model

Model|false
saveTranslation(array $data, string|null $language = null, string|integer|null $id = null)

Create or update translation

bool
removeTranslation(string|integer|null $id = null, string|null $language = null)

Delete translation

bool
removeTranslations(string|integer|null $id = null)

Delete all translations

Model|null
findTranslation(string $attributeName, mixed $value, string|null $language = null)

Find Translation

array
getMetaTags(string|null $language = null, array|null $default = [])

Get meta tags values

Details

at line 31
static void bootTranslations()

Boot trait.

Return Value

void

at line 44
string getCurrentLanguage()

Get current language

Return Value

string

at line 56
string|null translateAttribute(string $attribute, string|null $language = null)

Return translated value

Parameters

string $attribute
string|null $language

Return Value

string|null

at line 74
bool translateAttributes(string $language)

Translate attributes

Parameters

string $language

Return Value

bool

at line 95
array getTranslatedAttributes()

Get translation attributes

Return Value

array

at line 105
string|null getTranslationReferenceAttributeName()

Get translation refernce attribute name

Return Value

string|null

at line 115
string|null getTranslationModelClass()

Get translation miodel class

Return Value

string|null

at line 125
Relation|null translations()

HasMany relation

Return Value

Relation|null

at line 136
Builder getTranslationsQuery(string|null $language = null)

Get translations query

Parameters

string|null $language

Return Value

Builder

at line 152
Model|false translation(string|null $language = null, bool $query = false)

Get translation model

Parameters

string|null $language
bool $query

Return Value

Model|false

at line 169
Model|false saveTranslation(array $data, string|null $language = null, string|integer|null $id = null)

Create or update translation

Parameters

array $data
string|null $language
string|integer|null $id

Return Value

Model|false

at line 195
bool removeTranslation(string|integer|null $id = null, string|null $language = null)

Delete translation

Parameters

string|integer|null $id
string|null $language

Return Value

bool

at line 210
bool removeTranslations(string|integer|null $id = null)

Delete all translations

Parameters

string|integer|null $id

Return Value

bool

at line 226
Model|null findTranslation(string $attributeName, mixed $value, string|null $language = null)

Find Translation

Parameters

string $attributeName
mixed $value
string|null $language

Return Value

Model|null

at line 243
array getMetaTags(string|null $language = null, array|null $default = [])

Get meta tags values

Parameters

string|null $language
array|null $default

Return Value

array