Files
ntspi-app/app/Observers/ContactWidgetObserver.php
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

59 lines
1.6 KiB
PHP

<?php
namespace App\Observers;
use App\Containers\Widget\Models\ContactWidget;
use App\Services\App\Cache\ContactWidgetCacheService;
class ContactWidgetObserver
{
private ContactWidgetCacheService $contactWidgetCacheService;
public function __construct()
{
$this->contactWidgetCacheService = app(ContactWidgetCacheService::class);
}
/**
* Handle the ContactWidget "created" event.
*/
public function created(ContactWidget $contactWidget): void
{
$this->contactWidgetCacheService->clearAllCacheByModel();
}
/**
* Handle the ContactWidget "updated" event.
*/
public function updated(ContactWidget $contactWidget): void
{
$this->contactWidgetCacheService->clearCache($contactWidget);
$this->contactWidgetCacheService->clearAllCacheByModel();
}
/**
* Handle the ContactWidget "deleted" event.
*/
public function deleted(ContactWidget $contactWidget): void
{
$this->contactWidgetCacheService->clearCache($contactWidget);
$this->contactWidgetCacheService->clearAllCacheByModel();
}
/**
* Handle the ContactWidget "restored" event.
*/
public function restored(ContactWidget $contactWidget): void
{
$this->contactWidgetCacheService->clearAllCacheByModel();
}
/**
* Handle the ContactWidget "force deleted" event.
*/
public function forceDeleted(ContactWidget $contactWidget): void
{
$this->contactWidgetCacheService->clearCache($contactWidget);
$this->contactWidgetCacheService->clearAllCacheByModel();
}
}