33 lines
1.4 KiB
PHP
33 lines
1.4 KiB
PHP
<?php
|
|
use App\Jobs\TriggerNaksSyncJob;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
if (isset($data['source_project'])) {
|
|
// If source_project was changed or is empty (meaning this project is now the source)
|
|
// We should trigger a sync to other projects
|
|
|
|
// Check if it was actually changed or if this is a new record
|
|
// In SaveTrigger context, we might not have the old data easily accessible unless we query it or passed it
|
|
// But since this runs AFTER save, we can just trigger it if source_project is empty (owned by us)
|
|
// or if we want to propagate changes regardless.
|
|
|
|
// The requirement is: "When I make 'Viksa' empty, it is saved with this project's name and triggers others".
|
|
// Empty means "This Project".
|
|
|
|
$sourceProject = $data['source_project'];
|
|
|
|
// If source_project is empty/null, it means we originated/modified it as the master.
|
|
// If source_project is NOT empty, it means it belongs to another project, so normally we shouldn't be editing it
|
|
// unless we are "stealing" ownership or it's a sync update.
|
|
// However, if we are the one triggering the save (via UI), we should notify others.
|
|
|
|
// We'll trigger the sync job to notify others.
|
|
|
|
Log::info("SaveTrigger: naks_certificates updated. Dispatching TriggerNaksSyncJob.");
|
|
|
|
TriggerNaksSyncJob::dispatch([
|
|
'module' => 'technology',
|
|
'source_project' => config('app.name', 'Unknown Project'),
|
|
]);
|
|
}
|