Files
ntspi-app/app/Observers/TagObserver.php
T
2025-01-15 15:31:37 +05:00

57 lines
1.0 KiB
PHP

<?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
{
//
}
}