Files
citrus-cms/app/Http/Controllers/SaveTrigger/ndt_log_cache_clear.php
T
2026-04-28 21:14:25 +03:00

47 lines
1.5 KiB
PHP

<?php
use Illuminate\Support\Facades\Log;
/**
* Shared NDT Log Trigger Logic
*
* This file is included by individual NDT log save triggers to
* invalidate the 'request-ndt' cache when 'control_standart' changes.
*/
$shouldUpdate = false;
// If we have data and it has control_standart
if(isset($data) && property_exists($data, 'control_standart')) {
// If it's a new record (no beforeData) or if the value changed
// We also check if beforeData has the property, just in case
if(!isset($beforeData) || !property_exists($beforeData, 'control_standart') || $data->control_standart != $beforeData->control_standart) {
$shouldUpdate = true;
}
}
if($shouldUpdate) {
if(function_exists('dispatchCacheBladeViews')) {
dispatchCacheBladeViews([
[
'view' => 'admin-ajax.request-ndt-no-cache',
'cache' => 'request-ndt'
],
[
'view' => 'admin-ajax.ndt-calculation-no-cache',
'cache' => 'ndt-calculation'
],
[
'view' => 'admin-ajax.ndt-order.order-list-no-cache',
'cache' => 'ndt-order-list'
]
]);
Log::info("NDT Log triggered request-ndt cache update due to control_standart change.", [
'table' => $tableName ?? 'unknown',
'id' => $data->id ?? 'unknown',
'new_value' => $data->control_standart ?? 'null',
'old_value' => $beforeData->control_standart ?? 'null'
]);
}
}