Files
compras/app/Services/ReplenishmentHeartbeat.php
T
2026-11-03 11:51:44 +02:00

31 lines
1.1 KiB
PHP

<?php
namespace App\Services;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Facades\DB;
/** Technical observation only; contains no company data or business authority. */
class ReplenishmentHeartbeat
{
public function fingerprint(): string
{
$connection = DB::connection();
return hash('sha256', json_encode([base_path(), config('work_context.composition'), $connection->getDriverName(),
$connection->getConfig('host'), $connection->getConfig('port'), $connection->getDatabaseName()], JSON_THROW_ON_ERROR));
}
public function record(string $started, int $exitCode): void
{
app(Filesystem::class)->replace(storage_path('framework/replenishment-command-status.json'), json_encode([
'started_at' => $started,
'finished_at' => now()->toIso8601String(),
'scope' => 'SGC replenishment command',
'result' => $exitCode === 0 ? 'passed' : 'retry_pending',
'exit_code' => $exitCode,
'installation' => $this->fingerprint(),
], JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR));
}
}