spatie/laravel-settings

Cache not using getters, setters and casting

argonzalez2016 opened this issue · 2 comments

Discussed in #77

Originally posted by argonzalez2016 July 8, 2021
When I only use the database, settings are pulled properly.

If I cast to a Laravel collection, this works properly.

class CollectionCast implements SettingsCast 
{
    public function get($payload): Collection
    {
        return collect($payload);
    }

    public function set($payload): array
    {
        return $payload->toArray();
    }
}
public Collection $view_cache;    

public static function casts(): array
{
    return [
            'view_cache' => CollectionCast::class,
        ];
}

$setting->view_cache is a laravel collection and in the database is an array.

When I enable the cache, casting doesn't happen. The package only uses view_cache as an array and creates errors.

Hi @argonzalez2016,

This should be fixed in 2.3.1!

Awesome!