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;
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -19,7 +19,7 @@ Route::get('/testtry',function(ImbangdugaServices $imbangduga){
|
||||
|
||||
// return view('testing');
|
||||
$test = $imbangduga->OperationImbangDuga('KB2');
|
||||
dd($test);
|
||||
dd($test->getContent());
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user