Skip to content

fixed the cache doesnt load correctly Fixes #12 - #13

Open
djemmal-nour-el-islam wants to merge 1 commit into
MuhammadSadeeq:mainfrom
djemmal-nour-el-islam:fix-cache
Open

fixed the cache doesnt load correctly Fixes #12#13
djemmal-nour-el-islam wants to merge 1 commit into
MuhammadSadeeq:mainfrom
djemmal-nour-el-islam:fix-cache

Conversation

@djemmal-nour-el-islam

Copy link
Copy Markdown

the problem appear whith laravel sail and i dont know if the problem exist without laravel sail....
this fixe it for me

@MuhammadSadeeq

Copy link
Copy Markdown
Owner

Thanks for this, and for reporting the issue with the error message — that helped a lot.

You're onto something. These methods should be caching plain arrays instead of Collection
objects, so I want to keep the ->toArray() part.

The problem is the collect() wrapper. When the cached value is broken, collect()
doesn't fix it — it just wraps the broken object, so you get junk instead of the causer
list. The error goes away but the filter panel breaks in the browser instead, which is
harder to spot.

Also getEventTypesWithStyling() a bit further down does the same thing and runs in the
same request, so it can still break. And Cache::remember() skips the closure while
something's still cached, so ->toArray() won't help anyone who already has a bad entry
until it expires.

That last bit makes me wonder — when you tested the fix, did you also run
php artisan cache:clear? And what's your CACHE_STORE set to? The method returns a
normal Laravel Collection, which should always work, so I'd like to know what's actually
ending up on that cache key before I close the issue.

@djemmal-nour-el-islam

Copy link
Copy Markdown
Author

yes i have run php artisan cache:clear and i have CACHE_STORE=database

@djemmal-nour-el-islam

djemmal-nour-el-islam commented Aug 13, 2026

Copy link
Copy Markdown
Author

i have add now this and i think it solve the (Failed to load filter options)
` return collect(Cache::remember($cacheKey, 3600, function () {
$eventTypes = Activity::select('event')
->whereNotNull('event')
->distinct()
->pluck('event')
->values();

        return $eventTypes->map(function ($event, $index) {
            $styling = $this->generateEventTypeStyling($event, $index);

            return [
                'value' => $event,
                'label' => ucfirst($event),
                'colors' => $styling['colors'],
                'gradient' => $styling['gradient'],
                'icon' => $styling['icon'],
                'badge_classes' => $styling['badge_classes'],
                'timeline_classes' => $styling['timeline_classes'],
            ];
        });
    }))->values();    `

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants