PHP Class Polyglot\Polyglot

Inheritance: extends Illuminate\Database\Eloquent\Model
Show file Open project: anahkiasen/polyglot Class Usage Examples

Protected Properties

Property Type Description
$polyglot array The attributes to translate

Public Methods

Method Description
__call ( string $method, array $parameters ) : mixed Handle polyglot dynamic method calls for locale relations.
__get ( string $key ) : mixed Get a localized attribute
__isset ( string $key ) : boolean Checks if a field isset while taking into account localized attributes
getLangClass ( ) : string Get the Lang class corresponding to the current model
getPolyglotAttributes ( ) : array Get the polyglot attributes
lang ( string $lang = null ) : Illuminate\Database\Eloquent\Relations\HasOne Reroutes functions to the language in use
localize ( array $localization ) : boolean | null Localize a model with an array of lang arrays
scopeWithLang ( ) : Query Localize a "with" method
translations ( ) : Illuminate\Database\Eloquent\Relations\HasMany Get all translations

Protected Methods

Method Description
boot ( ) The "booting" method of the model.
getAvailable ( ) : array Get an array of supported locales

Method Details

__call() public method

Handle polyglot dynamic method calls for locale relations.
public __call ( string $method, array $parameters ) : mixed
$method string
$parameters array
return mixed

__get() public method

Get a localized attribute
public __get ( string $key ) : mixed
$key string The attribute
return mixed

__isset() public method

Checks if a field isset while taking into account localized attributes
public __isset ( string $key ) : boolean
$key string The key
return boolean

boot() protected static method

The "booting" method of the model.
protected static boot ( )

getAvailable() protected method

Get an array of supported locales
protected getAvailable ( ) : array
return array

getLangClass() public method

Get the Lang class corresponding to the current model
public getLangClass ( ) : string
return string

getPolyglotAttributes() public method

Get the polyglot attributes
public getPolyglotAttributes ( ) : array
return array

lang() public method

Reroutes functions to the language in use
public lang ( string $lang = null ) : Illuminate\Database\Eloquent\Relations\HasOne
$lang string A language to use
return Illuminate\Database\Eloquent\Relations\HasOne

localize() public method

Localize a model with an array of lang arrays
public localize ( array $localization ) : boolean | null
$localization array An array in the form [field][lang][value]
return boolean | null

scopeWithLang() public method

Localize a "with" method
public scopeWithLang ( ) : Query
return Query

translations() public method

Get all translations
public translations ( ) : Illuminate\Database\Eloquent\Relations\HasMany
return Illuminate\Database\Eloquent\Relations\HasMany

Property Details

$polyglot protected property

The attributes to translate
protected array $polyglot
return array