Files
2026-04-28 21:14:25 +03:00

67 lines
1.7 KiB
PHP

<?php
namespace App\Services\WeldLogTriggers\Triggers;
use App\Services\WeldLogTriggers\Base\BaseTrigger;
use Illuminate\Support\Facades\Log;
/**
* Test Pack Cleanup Trigger
*
* Deletes non-matching test pack statuses
* Cleans up orphaned test package records
*/
class TestPackCleanupTrigger extends BaseTrigger
{
public function getName(): string
{
return 'Test Pack Cleanup';
}
public function getOrder(): int
{
return 13;
}
public function getDependentFields(): array
{
return [
'test_package_no',
'iso_number'
];
}
protected function process($data, $beforeData, array $context): array
{
try {
// Call the cleanup view to delete non-matching test pack statuses
$result = view('cron.weld_logs-delete-non-matching-test-pack-statuses')->render();
Log::info("Test Pack Cleanup completed successfully", [
'weld_log_id' => $data->id
]);
return [
'success' => true,
'result' => 'cleanup_completed'
];
} catch (\Throwable $th) {
Log::error("Test Pack Cleanup failed (non-critical)", [
'weld_log_id' => $data->id,
'error' => $th->getMessage(),
'file' => $th->getFile(),
'line' => $th->getLine()
]);
// This is a non-critical operation, don't throw exception
return [
'success' => false,
'error' => $th->getMessage(),
'note' => 'non_critical_operation'
];
}
}
}