feat(webstatement): tambahkan command dan scheduler untuk generate biaya kartu ATM
- Menambahkan `GenerateBiayakartuCommand` untuk memproses biaya kartu ATM. - Mendaftarkan command baru di `WebstatementServiceProvider`. - Menjadwalkan command `webstatement:generate-biaya-kartu` pada tanggal 14 setiap bulan pukul 18:00. - Menambahkan log output untuk scheduler ke file `biaya-kartu-scheduler.log`. Signed-off-by: Daeng Deni Mardaeni <ddeni05@gmail.com>
This commit is contained in:
46
app/Console/GenerateBiayakartuCommand.php
Normal file
46
app/Console/GenerateBiayakartuCommand.php
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Webstatement\Console;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Modules\Webstatement\Jobs\BiayaKartu;
|
||||||
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
|
|
||||||
|
class GenerateBiayakartuCommand extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'webstatement:generate-biaya-kartu';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Proses Generate Biaya Kartu ATM';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*/
|
||||||
|
public function handle(): int
|
||||||
|
{
|
||||||
|
$this->info('Memulai proses biaya kartu ATM');
|
||||||
|
|
||||||
|
try {
|
||||||
|
BiayaKartu::dispatch();
|
||||||
|
$this->info('Job biaya kartu ATM berhasil dijadwalkan');
|
||||||
|
Log::info('Job biaya kartu ATM berhasil dijadwalkan oleh scheduler');
|
||||||
|
return Command::SUCCESS;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$this->error('Terjadi kesalahan: ' . $e->getMessage());
|
||||||
|
Log::error('Gagal menjalankan job biaya kartu ATM: ' . $e->getMessage());
|
||||||
|
return Command::FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
namespace Modules\Webstatement\Providers;
|
namespace Modules\Webstatement\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Console\Scheduling\Schedule;
|
||||||
use Illuminate\Support\Facades\Blade;
|
use Illuminate\Support\Facades\Blade;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
use Modules\Webstatement\Console\GenerateBiayakartuCommand;
|
||||||
use Nwidart\Modules\Traits\PathNamespace;
|
use Nwidart\Modules\Traits\PathNamespace;
|
||||||
|
|
||||||
class WebstatementServiceProvider extends ServiceProvider
|
class WebstatementServiceProvider extends ServiceProvider
|
||||||
@@ -45,7 +47,9 @@ class WebstatementServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
protected function registerCommands(): void
|
protected function registerCommands(): void
|
||||||
{
|
{
|
||||||
// $this->commands([]);
|
$this->commands([
|
||||||
|
GenerateBiayakartuCommand::class
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -53,10 +57,11 @@ class WebstatementServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
protected function registerCommandSchedules(): void
|
protected function registerCommandSchedules(): void
|
||||||
{
|
{
|
||||||
// $this->app->booted(function () {
|
$schedule = $this->app->make(Schedule::class);
|
||||||
// $schedule = $this->app->make(Schedule::class);
|
$schedule->command('webstatement:generate-biaya-kartu')
|
||||||
// $schedule->command('inspire')->hourly();
|
->monthlyOn(14, '18:00')
|
||||||
// });
|
->appendOutputTo(storage_path('logs/biaya-kartu-scheduler.log'));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user