PHP Trait Waavi\Translation\Traits\Translatable

Mostra file Open project: waavi/translation

Public Methods

Method Description
attributesToArray ( ) : array Extend parent's attributesToArray so that _translation attributes do not appear in array, and translatable attributes are translated.
bootTranslatable ( ) : void Register Model observer.
getAttribute ( $attribute ) : mixed Hijack parent's getAttribute to get the translation of the given field instead of its value.
getRawAttribute ( $attribute )
isTranslatable ( $attribute ) : boolean Check if an attribute is translatable.
isTranslated ( string $attribute ) : boolean Check if a translation exists for the given attribute.
rawValueRequested ( string $attribute ) : boolean Check if the attribute being queried is the raw value of a translatable attribute.
setAttribute ( string $attribute, string $value ) : void Hijack Eloquent's setAttribute to create a Language Entry, or update the existing one, when setting the value of this attribute.
translatableAttributes ( ) : array Return the translatable attributes array
translate ( string $attribute ) : Translation Return the translation related to a translatable attribute.
translationCodeFor ( string $attribute ) : string Get the set translation code for the give attribute

Method Details

attributesToArray() public method

@return array
public attributesToArray ( ) : array
return array

bootTranslatable() public static method

@return void
public static bootTranslatable ( ) : void
return void

getAttribute() public method

@param string $key Attribute name
public getAttribute ( $attribute ) : mixed
return mixed

getRawAttribute() public method

public getRawAttribute ( $attribute )
$attribute

isTranslatable() public method

@return boolean
public isTranslatable ( $attribute ) : boolean
return boolean

isTranslated() public method

@param string $attribute
public isTranslated ( string $attribute ) : boolean
$attribute string
return boolean

rawValueRequested() public method

@param string $attribute
public rawValueRequested ( string $attribute ) : boolean
$attribute string
return boolean

setAttribute() public method

@param string $attribute Attribute name
public setAttribute ( string $attribute, string $value ) : void
$attribute string
$value string Text value in default locale. @return void
return void

translatableAttributes() public method

@return array
public translatableAttributes ( ) : array
return array

translate() public method

@param string $attribute
public translate ( string $attribute ) : Translation
$attribute string
return Translation

translationCodeFor() public method

@param string $attribute
public translationCodeFor ( string $attribute ) : string
$attribute string
return string