Skip to content

Commit 5b802a6

Browse files
committed
Update: Clear banner cache after create or update
1 parent 3e12ddf commit 5b802a6

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/Models/Banner.php

+17
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Filament\View\PanelsRenderHook;
88
use Illuminate\Database\Eloquent\Factories\HasFactory;
99
use Illuminate\Database\Eloquent\Model;
10+
use Illuminate\Support\Facades\Cache;
1011
use Laragear\TwoFactor\Contracts\TwoFactorAuthenticatable;
1112
use Visualbuilder\Filament2fa\Database\Factories\BannerFactory;
1213

@@ -46,6 +47,22 @@ class Banner extends Model
4647

4748
protected $table = 'two_factor_banners';
4849

50+
protected static function booted()
51+
{
52+
parent::booted();
53+
54+
// When a banner is created or updated
55+
static::saved(function ($banner) {
56+
Cache::forget('all_banners');
57+
});
58+
59+
// When a banner is deleted
60+
static::deleted(function ($banner) {
61+
Cache::forget('all_banners');
62+
});
63+
}
64+
65+
4966
/**
5067
* @return BannerFactory
5168
*/

0 commit comments

Comments
 (0)