whitecube / nova-flexible-content

Flexible Content & Repeater Fields for Laravel Nova
MIT License
788 stars 228 forks source link

Force cast for manipulate Flexible in Nova #414

Open jordansitbon opened 1 year ago

jordansitbon commented 1 year ago

Hello,

It's possible to add $force params in flexible trait ?

    public function flexible($attribute, $layoutMapping = [], $force = false)
    {
        $flexible = data_get($this->attributes, $attribute);

        return $this->cast($flexible, $layoutMapping, $force);
    }

    public function cast($value, $layoutMapping = [], $force = false)
    {
        if (!$force && app()->getProvider(NovaServiceProvider::class) && ! app()->runningInConsole()) {
            return $value;
        }

        return $this->toFlexible($value ?: null, $layoutMapping);
    }
Dartui commented 1 year ago

Please look at #409, I've made PR which enables cast of Flexible field everywhere