- Menghapus opsi `--date` dan `--type` dari command `webstatement:process-daily-migration` dan menggantinya dengan opsi baru `--process_parameter`. - Memperbarui pesan log pada eksekusi command untuk mencatat nilai `process_parameter` sebagai pengganti parameter `date` dan `type`. - Memperbarui logika pengiriman parameter ke controller: - Sebelumnya mengirimkan `date` dan `type`, kini diganti menjadi `process_parameter`. - Tujuan perubahan ini: - Menyederhanakan pengaturan parameter untuk command migrasi harian. - Memberikan fleksibilitas lebih dalam penanganan parameter proses migrasi. Signed-off-by: Daeng Deni Mardaeni <ddeni05@gmail.com>
54 lines
1.6 KiB
PHP
54 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace Modules\Webstatement\Console;
|
|
|
|
use Exception;
|
|
use Illuminate\Console\Command;
|
|
use Modules\Webstatement\Http\Controllers\MigrasiController;
|
|
|
|
class ProcessDailyMigration extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'webstatement:process-daily-migration
|
|
{--process_parameter= : To process migration parameter true/false}';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Process data migration for the previous day\'s period';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return int
|
|
*/
|
|
public function handle()
|
|
{
|
|
$processParameter = $this->option('process_parameter');
|
|
|
|
$this->info('Starting daily data migration process...');
|
|
$this->info('Process Parameter: ' . ($processParameter ?? 'False'));
|
|
|
|
try {
|
|
$controller = app(MigrasiController::class);
|
|
$response = $controller->index([
|
|
'process_parameter' => $processParameter
|
|
]);
|
|
|
|
$responseData = json_decode($response->getContent(), true);
|
|
$this->info($responseData['message'] ?? 'Process completed');
|
|
|
|
return Command::SUCCESS;
|
|
} catch (Exception $e) {
|
|
$this->error('Error processing daily migration: ' . $e->getMessage());
|
|
return Command::FAILURE;
|
|
}
|
|
}
|
|
}
|