public function getAttribute($key)
    {
        //set default language
        if(!$this->_defaultTranslateLanguage) {
            $this->setDefaultTranslateLanguage();
        }

        // In case we just need the translation for current property
        if(!$this->getTranslateLanguage()) {
            $this->translate($this->_defaultTranslateLanguage);
        }

        if(method_exists($this, 'isCustomField') && $this->isCustomField($key)) {
            $value = $this->customFieldValue($key);

            // If the given $attribute has a mutator, we push it to $attributes and then call getAttributeValue
            // on it. This way, we can use Eloquent's checking for Mutation, type casting, and
            // Date fields.
            if ($this->hasGetMutator($key)) {
                $this->attributes[$key] = $value;
                $value = $this->getAttributeValue($key);
            }
        }else{
            //is translatable value
            $value = parent::getAttribute($key);

            if ($this->autoTranslate && $this->isTranslatable($value, $key)) {

                // If the given $attribute has a mutator, we push it to $attributes and then call getAttributeValue
                // on it. This way, we can use Eloquent's checking for Mutation, type casting, and
                // Date fields.
                if ($this->hasGetMutator($key)) {
                    $this->attributes[$key] = $this->getTranslation($value);
                    $value = $this->getAttributeValue($key);
                }else {
                    $value = $this->getTranslation($value);
                }

                // we don't need current language any more, we have the default une
                $this->resetTranslateLanguage();
            }else{

                // If the given $attribute has a mutator, we push it to $attributes and then call getAttributeValue
                // on it. This way, we can use Eloquent's checking for Mutation, type casting, and
                // Date fields.
                if ($this->hasGetMutator($key)) {
                    $this->attributes[$key] = $value;
                    $value =  $this->getAttributeValue($key);
                }
            }
        }
        //handle custom fields

        return $value;
    }
public function getAttribute($key)
    {
        //set default language
        if(!$this->_defaultTranslateLanguage) {
            $this->setDefaultTranslateLanguage();
        }

        // In case we just need the translation for current property
        if(!$this->getTranslateLanguage()) {
            $this->translate($this->_defaultTranslateLanguage);
        }

        if(method_exists($this, 'isCustomField') && $this->isCustomField($key)) {
            $value = $this->customFieldValue($key);

            // If the given $attribute has a mutator, we push it to $attributes and then call getAttributeValue
            // on it. This way, we can use Eloquent's checking for Mutation, type casting, and
            // Date fields.
            if ($this->hasGetMutator($key)) {
                $this->attributes[$key] = $value;
                $value = $this->getAttributeValue($key);
            }
        }else{
            //is translatable value
            $value = parent::getAttribute($key);

            if ($this->autoTranslate && $this->isTranslatable($value, $key)) {

                // If the given $attribute has a mutator, we push it to $attributes and then call getAttributeValue
                // on it. This way, we can use Eloquent's checking for Mutation, type casting, and
                // Date fields.
                if ($this->hasGetMutator($key)) {
                    $this->attributes[$key] = $this->getTranslation($value);
                    $value = $this->getAttributeValue($key);
                }else {
                    $value = $this->getTranslation($value);
                }

                // we don't need current language any more, we have the default une
                $this->resetTranslateLanguage();
            }else{

                // If the given $attribute has a mutator, we push it to $attributes and then call getAttributeValue
                // on it. This way, we can use Eloquent's checking for Mutation, type casting, and
                // Date fields.
                if ($this->hasGetMutator($key)) {
                    $this->attributes[$key] = $value;
                    $value =  $this->getAttributeValue($key);
                }
            }
        }
        //handle custom fields

        return $value;
    }
public function getAttribute ( $ key ) { //set default language if ( ! $ this -> _defaultTranslateLanguage ) { $ this -> setDefaultTranslateLanguage ( ) ; } // In case we just need the translation for current property if ( ! $ this -> getTranslateLanguage ( ) ) { $ this -> translate ( $ this -> _defaultTranslateLanguage ) ; } if ( method_exists ( $ this , 'isCustomField' ) && $ this -> isCustomField ( $ key ) ) { $ value = $ this -> customFieldValue ( $ key ) ; // If the given $attribute has a mutator, we push it to $attributes and then call getAttributeValue // on it. This way, we can use Eloquent's checking for Mutation, type casting, and // Date fields. if ( $ this -> hasGetMutator ( $ key ) ) { $ this -> attributes [ $ key ] = $ value ; $ value = $ this -> getAttributeValue ( $ key ) ; } } else { //is translatable value $ value = parent :: getAttribute ( $ key ) ; if ( $ this -> autoTranslate && $ this -> isTranslatable ( $ value , $ key ) ) { // If the given $attribute has a mutator, we push it to $attributes and then call getAttributeValue // on it. This way, we can use Eloquent's checking for Mutation, type casting, and // Date fields. if ( $ this -> hasGetMutator ( $ key ) ) { $ this -> attributes [ $ key ] = $ this -> getTranslation ( $ value ) ; $ value = $ this -> getAttributeValue ( $ key ) ; } else { $ value = $ this -> getTranslation ( $ value ) ; } // we don't need current language any more, we have the default une $ this -> resetTranslateLanguage ( ) ; } else { // If the given $attribute has a mutator, we push it to $attributes and then call getAttributeValue // on it. This way, we can use Eloquent's checking for Mutation, type casting, and // Date fields. if ( $ this -> hasGetMutator ( $ key ) ) { $ this -> attributes [ $ key ] = $ value ; $ value = $ this -> getAttributeValue ( $ key ) ; } } } //handle custom fields return $ value ; }
Get class attributes.

@param string $key

@return mixed
Get class attributes .