İlk temizlik tamamlandı bir önceki projeden
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Models\NaksCertificate;
|
||||
use App\Jobs\TriggerNaksSyncJob;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class NaksCertificateObserver
|
||||
{
|
||||
/**
|
||||
* Handle the NaksCertificate "updated" event.
|
||||
*
|
||||
* @param \App\Models\NaksCertificate $naksCertificate
|
||||
* @return void
|
||||
*/
|
||||
public function updated(NaksCertificate $naksCertificate)
|
||||
{
|
||||
// Check if source_project was changed
|
||||
if ($naksCertificate->wasChanged('source_project')) {
|
||||
$newSource = $naksCertificate->source_project;
|
||||
|
||||
// If the source_project is now empty (NULL or ''), it means this project effectively
|
||||
// took ownership or created a new version that should be treated as master.
|
||||
// Or if we specifically want to propagate ANY change to source_project.
|
||||
|
||||
// The user said: "When I make 'Viksa' empty, it is saved with this project's name
|
||||
// and triggers others".
|
||||
|
||||
// Assuming the "saved with this project's name" is logic handled elsewhere or implied
|
||||
// by it being empty (Empty = This Project).
|
||||
|
||||
// We trigger the sync job.
|
||||
Log::info("NaksCertificate updated: source_project changed to '{$newSource}'. Dispatching TriggerNaksSyncJob.");
|
||||
|
||||
TriggerNaksSyncJob::dispatch([
|
||||
'module' => 'technology', // naks_certificates corresponds to technology module
|
||||
'source_project' => config('app.name', 'Unknown Project'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Jobs\TriggerNaksSyncJob;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class NaksConsumablesObserver
|
||||
{
|
||||
public function updated($model)
|
||||
{
|
||||
if ($model->wasChanged('source_project')) {
|
||||
Log::info("NaksConsumables updated: source_project changed. Dispatching TriggerNaksSyncJob.");
|
||||
|
||||
TriggerNaksSyncJob::dispatch([
|
||||
'module' => 'consumables',
|
||||
'source_project' => config('app.name', 'Unknown Project'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Jobs\TriggerNaksSyncJob;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class NaksWeldersObserver
|
||||
{
|
||||
public function updated($model)
|
||||
{
|
||||
if ($model->wasChanged('source_project')) {
|
||||
Log::info("NaksWelders updated: source_project changed. Dispatching TriggerNaksSyncJob.");
|
||||
|
||||
TriggerNaksSyncJob::dispatch([
|
||||
'module' => 'welder',
|
||||
'source_project' => config('app.name', 'Unknown Project'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Jobs\TriggerNaksSyncJob;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class RegisterOfExpertsObserver
|
||||
{
|
||||
public function updated($model)
|
||||
{
|
||||
if ($model->wasChanged('source_project')) {
|
||||
Log::info("RegisterOfExperts updated: source_project changed. Dispatching TriggerNaksSyncJob.");
|
||||
|
||||
TriggerNaksSyncJob::dispatch([
|
||||
'module' => 'expert',
|
||||
'source_project' => config('app.name', 'Unknown Project'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Jobs\TriggerNaksSyncJob;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class WeldingEquipmentObserver
|
||||
{
|
||||
public function updated($model)
|
||||
{
|
||||
if ($model->wasChanged('source_project')) {
|
||||
Log::info("WeldingEquipment updated: source_project changed. Dispatching TriggerNaksSyncJob.");
|
||||
|
||||
TriggerNaksSyncJob::dispatch([
|
||||
'module' => 'equipment',
|
||||
'source_project' => config('app.name', 'Unknown Project'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user