swisnl / filament-backgrounds

Beautiful backgrounds for Filament auth pages
MIT License
38 stars 4 forks source link

[Bug]: Cache Image per FilamentPanel #8

Closed eelco2k closed 9 months ago

eelco2k commented 9 months ago

What happened?

When having multiple Filament Panels the same cached image returns for each panel. even though i've registered another imageProvider

How to reproduce the bug

create multiple filament panels

one panel add

$panel->plugin([FilamentBackgroundsPlugin::make()->remember(60)]

other panel add:

$panel2->plugin([FilamentBackgroundsPlugin::make()->imageProvider(Triangles::make())->remember(60)]

open both panels with login page.

proposed update:

in FilamentBackgroundsPlugin.php change this function so that it gets the correct cached image per filament panel:


protected function getImage(): Image
    {

        return Cache::remember(
            Filament::getCurrentPanel()->getId() ?? '' . 'filament-backgrounds:image',
            $this->ttl,
            fn () => ($this->imageProvider ?? CuratedBySwis::make())->getImage()
        );
    }

Package Version

1.1.1

PHP Version

8.3.2

Laravel Version

10

Which operating systems does with happen with?

No response

Notes

No response

JaZo commented 9 months ago

Good catch, thanks for reporting! Fixed in 1.1.2.