Files
ntspi-app/app/Observers/CategoryObserver.php
T
F4ilji c01016a154 Migrate backend to Porto architecture and fix minor bugs
- Fully transitioned the backend to the Porto architectural pattern
- Improved code organization and maintainability
- Fixed minor bugs and inconsistencies
2025-05-12 08:47:43 +05:00

57 lines
1.1 KiB
PHP

<?php
namespace App\Observers;
use App\Containers\Article\Models\Category;
use App\Services\App\Cache\CategoryCacheService;
class CategoryObserver
{
protected CategoryCacheService $categoryCacheService;
public function __construct()
{
$this->categoryCacheService = new CategoryCacheService();
}
/**
* Handle the Post "created" event.
*/
public function saved(Category $category): void
{
$this->categoryCacheService->clearAllCacheByModel();
}
/**
* Handle the Post "updated" event.
*/
public function updated(Category $category)
{
$this->categoryCacheService->clearAllCacheByModel();
}
/**
* Очистка кеша при удалении поста.
*/
public function deleted(Category $category)
{
$this->categoryCacheService->clearAllCacheByModel();
}
/**
* Handle the Post "restored" event.
*/
public function restored(Category $category): void
{
//
}
/**
* Handle the Post "force deleted" event.
*/
public function forceDeleted(Category $category): void
{
//
}
}