From e326a22f4b695f0cf093081a680d0d30fa508594 Mon Sep 17 00:00:00 2001 From: Hafifie PKB Date: Sat, 31 May 2025 22:26:14 +0800 Subject: [PATCH] added update cron ig all --- app/Console/Commands/updateImbangDuga.php | 81 +++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 app/Console/Commands/updateImbangDuga.php diff --git a/app/Console/Commands/updateImbangDuga.php b/app/Console/Commands/updateImbangDuga.php new file mode 100644 index 0000000..897958f --- /dev/null +++ b/app/Console/Commands/updateImbangDuga.php @@ -0,0 +1,81 @@ +option('all')){ + $zone = 'all'; + }else if($this->option('1')){ + $zone = '1'; + }else if ($this->option('2')){ + $zone = '2'; + }else if ($this->option('3')){ + $zone = '3'; + } + + $monthly = Carbon::now(); + $monthly = new Carbon(); + + $previousmonth = $monthly->subMonthsNoOverflow()->endOfMonth(); + $tahun = $previousmonth->year; + $month = $previousmonth->month; + + $response = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/reports/updateigall',[ + 'month' => $month, + 'year' => $tahun, + ]); + + if ($response->successful()) { + $data = $response->json(); + Log::info()('Imbang Duga update successful', [ + 'month' => $month, + 'year' => $tahun, + 'data' => $data + ]); + $this->info('Imbang Duga update successful'); + } else { + Log::error('API error', [ + 'url' => $response->effectiveUri(), + 'status' => $response->status(), + 'body' => $response->body() + ]); + } + } +}