İlk temizlik tamamlandı bir önceki projeden
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\LineListTriggers\Triggers;
|
||||
|
||||
use App\Services\LineListTriggers\Base\BaseLineListTrigger;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Isolation Sync Trigger
|
||||
*
|
||||
* Syncs external_finish_type from Line List to:
|
||||
* - Test Packages (isolation field)
|
||||
* Triggered when external_finish_type field changes in Line List
|
||||
*/
|
||||
class IsolationSyncTrigger extends BaseLineListTrigger
|
||||
{
|
||||
public function getName(): string
|
||||
{
|
||||
return 'Isolation Sync';
|
||||
}
|
||||
|
||||
public function getDependentFields(): array
|
||||
{
|
||||
return ['external_finish_type'];
|
||||
}
|
||||
|
||||
protected function process($lineListData, $beforeData, array $context): array
|
||||
{
|
||||
// Update 'isolation' field in test_packages table where p_id matches line_no
|
||||
// 1. Get test_package_no's from test_pack_base_statuses where drawing_no matches line_no
|
||||
$testPackageNos = db('test_pack_base_statuses')
|
||||
->where('drawing_no', $lineListData->line_no)
|
||||
->pluck('test_package_no')
|
||||
->toArray();
|
||||
|
||||
// 2. Update test_packages where test_package_no matches the found ones
|
||||
if (!empty($testPackageNos)) {
|
||||
$result = db("test_packages")
|
||||
->whereIn("test_package_number", $testPackageNos)
|
||||
->update([
|
||||
'isolation' => $lineListData->external_finish_type
|
||||
]);
|
||||
} else {
|
||||
$result = 0;
|
||||
}
|
||||
|
||||
Log::info("Line List Isolation Sync completed", [
|
||||
'line_no' => $lineListData->line_no,
|
||||
'external_finish_type' => $lineListData->external_finish_type,
|
||||
'updated' => $result,
|
||||
]);
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
'test_packages_updated' => $result,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user