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

29 lines
831 B
PHP

<?php
$id = $request['key'];
// Get the paint matrix record before deletion
$paintMatrix = db('paint_matrices')->where('id', $id)->first();
if ($paintMatrix) {
// Delete from paint_follow_ups
db('paint_follow_ups')
->where([
'line' => $paintMatrix->line,
'area' => $paintMatrix->area,
])
->whereNull('primer_coating_start_date') // Only delete if primer coating start date is null
->delete();
// Delete from construction_paint_logs
db('construction_paint_logs')
->where([
'line' => $paintMatrix->line,
'unit' => $paintMatrix->area,
])
->whereNull('painting_date_1') // Only delete if primer coating start date is null
->delete();
dump("Deleted related records for paint matrix ID: $id");
}
?>