This commit is contained in:
f4ilji
2025-01-15 15:31:37 +05:00
parent 45e73e27a0
commit bad611eb84
27 changed files with 815 additions and 124 deletions
+56
View File
@@ -0,0 +1,56 @@
<?php
namespace App\Observers;
use App\Models\Tag;
use App\Services\App\Cache\TagCacheService;
class TagObserver
{
protected TagCacheService $tagCacheService;
public function __construct()
{
$this->tagCacheService = new TagCacheService();
}
/**
* Handle the Post "created" event.
*/
public function saved(Tag $tag): void
{
$this->tagCacheService->clearAllCacheByModel();
}
/**
* Handle the Post "updated" event.
*/
public function updated(Tag $tag)
{
$this->tagCacheService->clearAllCacheByModel();
}
/**
* Очистка кеша при удалении поста.
*/
public function deleted(Tag $tag)
{
$this->tagCacheService->clearAllCacheByModel();
}
/**
* Handle the Post "restored" event.
*/
public function restored(Tag $tag): void
{
//
}
/**
* Handle the Post "force deleted" event.
*/
public function forceDeleted(Tag $tag): void
{
//
}
}