Files
construprogress/app/Observers/InspectionObserver.php
T

26 lines
559 B
PHP
Raw Normal View History

<?php
namespace App\Observers;
use App\Models\Inspection;
use Illuminate\Support\Facades\Cache;
class InspectionObserver
{
public function saved(Inspection $inspection): void
{
$this->clearReportCache($inspection->project_id);
}
public function deleted(Inspection $inspection): void
{
$this->clearReportCache($inspection->project_id);
}
private function clearReportCache(?int $projectId): void
{
if ($projectId) {
Cache::tags(["report:project:{$projectId}"])->flush();
}
}
}