Files
hafifierahman 81e7c47229 add commands
2022-12-18 10:56:26 +08:00

62 lines
1.3 KiB
PHP

<?php
namespace App\Console\Commands;
use Exception;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Http;
class DailyAkru extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'akru:daily {--zone=1 : Choose which zone to update zone [1,2,3]}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Generate Daily Akrual For Trial Balance';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$zone = $this->option('zone');
if($zone < 1 || $zone > 3)
{
throw new Exception('The zone is not in the range!');
}
$updateAkruDaily = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/admin/laporan/akrual/generateDaily',[
'zone' => $zone
])->json();
if($updateAkruDaily == 'succesful')
{
return 0;
}else{
return 'failed';
}
}
}