protected function getElementValue(Model $model, NamedFormElement $el)
    {
        $attribute = $el->getModelAttributeKey();
        if (strpos($attribute, '->') === false) {
            return $model->getAttribute($attribute);
        }

        // Parse json attributes
        $casts = collect($model->getCasts());
        $jsonParts = collect(explode('->', $attribute));
        $cast = $casts->get($jsonParts->first(), false);

        if (! in_array($cast, ['json', 'array'])) {
            return;
        }

        $jsonAttr = $model->{$jsonParts->first()};

        return array_get($jsonAttr, $jsonParts->slice(1)->implode('.'));
    }
protected function getElementValue(Model $model, NamedFormElement $el)
    {
        $attribute = $el->getModelAttributeKey();
        if (strpos($attribute, '->') === false) {
            return $model->getAttribute($attribute);
        }

        // Parse json attributes
        $casts = collect($model->getCasts());
        $jsonParts = collect(explode('->', $attribute));
        $cast = $casts->get($jsonParts->first(), false);

        if (! in_array($cast, ['json', 'array'])) {
            return;
        }

        $jsonAttr = $model->{$jsonParts->first()};

        return array_get($jsonAttr, $jsonParts->slice(1)->implode('.'));
    }
protected function getElementValue ( Model $ model , NamedFormElement $ el ) { $ attribute = $ el -> getModelAttributeKey ( ) ; if ( strpos ( $ attribute , '->' ) === false ) { return $ model -> getAttribute ( $ attribute ) ; } // Parse json attributes $ casts = collect ( $ model -> getCasts ( ) ) ; $ jsonParts = collect ( explode ( '->' , $ attribute ) ) ; $ cast = $ casts -> get ( $ jsonParts -> first ( ) , false ) ; if ( ! in_array ( $ cast , [ 'json' , 'array' ] ) ) { return ; } $ jsonAttr = $ model -> { $ jsonParts -> first ( ) } ; return array_get ( $ jsonAttr , $ jsonParts -> slice ( 1 ) -> implode ( '.' ) ) ; }
Returns value from model for given element.

@param \Illuminate\Database\Eloquent\Model $model
@param NamedFormElement $el

@return mixed|null
Returns value from model for given element .