src/Gzero/Cms/ViewModels/ContentViewModel.php
public function seoDescription($alternativeField = false)
    {
        $descLength = option('seo', 'desc_length', config('gzero.seo.desc_length', 160));
        if (!$alternativeField) {
            $alternativeField = config('gzero-cms.seo.alternative_desc', 'body');
        }
        // if SEO description is set
        if ($this->translation['seo_description']) {
            return $this->removeNewLinesAndWhitespace($this->translation['seo_description']);
        }

        $text = $this->removeNewLinesAndWhitespace($this->translation[$alternativeField]);
        // if alternative field is not empty
        if ($text) {
            return strlen($text) >= $descLength ? substr($text, 0, strpos($text, ' ', $descLength)) : $text;
        };
        // show site description as default
        return option('general', 'site_desc');
    }
public function seoDescription($alternativeField = false)
    {
        $descLength = option('seo', 'desc_length', config('gzero.seo.desc_length', 160));
        if (!$alternativeField) {
            $alternativeField = config('gzero-cms.seo.alternative_desc', 'body');
        }
        // if SEO description is set
        if ($this->translation['seo_description']) {
            return $this->removeNewLinesAndWhitespace($this->translation['seo_description']);
        }

        $text = $this->removeNewLinesAndWhitespace($this->translation[$alternativeField]);
        // if alternative field is not empty
        if ($text) {
            return strlen($text) >= $descLength ? substr($text, 0, strpos($text, ' ', $descLength)) : $text;
        };
        // show site description as default
        return option('general', 'site_desc');
    }
public function seoDescription ( $ alternativeField = false ) { $ descLength = option ( 'seo' , 'desc_length' , config ( 'gzero.seo.desc_length' , 160 ) ) ; if ( ! $ alternativeField ) { $ alternativeField = config ( 'gzero-cms.seo.alternative_desc' , 'body' ) ; } // if SEO description is set if ( $ this -> translation [ 'seo_description' ] ) { return $ this -> removeNewLinesAndWhitespace ( $ this -> translation [ 'seo_description' ] ) ; } $ text = $ this -> removeNewLinesAndWhitespace ( $ this -> translation [ $ alternativeField ] ) ; // if alternative field is not empty if ( $ text ) { return strlen ( $ text ) >= $ descLength ? substr ( $ text , 0 , strpos ( $ text , ' ' , $ descLength ) ) : $ text ; } ; // show site description as default return option ( 'general' , 'site_desc' ) ; }
Return seoDescription of translation if exists
otherwise return generated one

@param mixed $alternativeField alternative field to display when seoDescription field is empty

@return string
Return seoDescription of translation if exists otherwise return generated one