add commands
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
@@ -12,7 +13,7 @@ class DailyAkru extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'akru:daily {--zone=1 : Choose which zone to update}';
|
||||
protected $signature = 'akru:daily {--zone=1 : Choose which zone to update zone [1,2,3]}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
@@ -40,6 +41,12 @@ class DailyAkru extends Command
|
||||
{
|
||||
$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();
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Services\ImbangdugaServices;
|
||||
|
||||
class DailyImbangDuga extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'imbangduga:daily {--zone=1 : Choose which zone to update [1,2,3]}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Save Trial Balance in Database Daily';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
private $imbangduga;
|
||||
|
||||
public function __construct(ImbangdugaServices $imbangduga)
|
||||
{
|
||||
$this->imbangduga = $imbangduga;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$array_cawangan = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan')->json();
|
||||
$zone = $this->option('zone');
|
||||
|
||||
if($zone < 1 || $zone > 3)
|
||||
{
|
||||
throw new Exception('The zone is not in the range!');
|
||||
}
|
||||
|
||||
foreach($array_cawangan as $caw)
|
||||
{
|
||||
if($caw['zone'] == $zone)
|
||||
{
|
||||
$response = $this->imbangduga->OperationImbangDuga($caw['kodcaw']);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user