diff --git a/app/Console/Commands/DailyAkru.php b/app/Console/Commands/DailyAkru.php index 9afbfce..83efce4 100644 --- a/app/Console/Commands/DailyAkru.php +++ b/app/Console/Commands/DailyAkru.php @@ -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(); diff --git a/app/Console/Commands/DailyImbangDuga.php b/app/Console/Commands/DailyImbangDuga.php new file mode 100644 index 0000000..a3637fe --- /dev/null +++ b/app/Console/Commands/DailyImbangDuga.php @@ -0,0 +1,65 @@ +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; + } +} diff --git a/app/Services/ImbangdugaServices.php b/app/Services/ImbangdugaServices.php index cff31a2..b3346e5 100644 --- a/app/Services/ImbangdugaServices.php +++ b/app/Services/ImbangdugaServices.php @@ -4,7 +4,6 @@ namespace App\Services; use App\CawanganAR; use App\ImbangDuga; -use Illuminate\Http\Request; use Illuminate\Support\Facades\Http; use Carbon\Carbon; @@ -138,7 +137,6 @@ class ImbangdugaServices 'tagtally' => $tagtally, ])->json(); - dd($insert_imbangduga_backup); if($insert_imbangduga_backup == 'success') return 'successful'; else @@ -201,6 +199,8 @@ class ImbangdugaServices if($response == 'successful'){ return response('succesful'); + }else{ + return response('error'); } } } \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index c13cbc3..3d5f47d 100644 --- a/routes/web.php +++ b/routes/web.php @@ -19,7 +19,7 @@ Route::get('/testtry',function(ImbangdugaServices $imbangduga){ // return view('testing'); $test = $imbangduga->OperationImbangDuga('KB2'); - dd($test); + dd($test->getContent()); });