2024-08-22 17:04:07 -04:00
|
|
|
<?php
|
|
|
|
|
2025-01-30 00:23:55 -05:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2024-08-22 17:04:07 -04:00
|
|
|
namespace App\Observers;
|
|
|
|
|
|
|
|
use App\Models\ModVersion;
|
|
|
|
use App\Services\SptVersionService;
|
|
|
|
|
|
|
|
class SptVersionObserver
|
|
|
|
{
|
2025-01-30 00:23:55 -05:00
|
|
|
public function __construct(protected SptVersionService $sptVersionService) {}
|
2024-08-22 17:04:07 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle the SptVersion "saved" event.
|
|
|
|
*/
|
|
|
|
public function saved(): void
|
|
|
|
{
|
|
|
|
$this->resolveSptVersion();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resolve the SptVersion's dependencies.
|
|
|
|
*/
|
|
|
|
private function resolveSptVersion(): void
|
|
|
|
{
|
|
|
|
$modVersions = ModVersion::all();
|
|
|
|
|
|
|
|
foreach ($modVersions as $modVersion) {
|
|
|
|
$this->sptVersionService->resolve($modVersion);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle the SptVersion "deleted" event.
|
|
|
|
*/
|
|
|
|
public function deleted(): void
|
|
|
|
{
|
|
|
|
$this->resolveSptVersion();
|
|
|
|
}
|
|
|
|
}
|