diff --git a/app/Console/Commands/syncHumanResourceIntegration.php b/app/Console/Commands/syncHumanResourceIntegration.php new file mode 100644 index 0000000..0f3b72d --- /dev/null +++ b/app/Console/Commands/syncHumanResourceIntegration.php @@ -0,0 +1,77 @@ +message != 'success') + return; + + if(!is_int($response->total) || $response->total == 0) + return; + + $totalPage = $response->last_page; + echo "\nTotal Page = " . $totalPage; + $currentResponse = $response; + for($i = 1; $i <= $totalPage; $i++){ + echo "\nCurrent Page = " . $i; + $employeesPageData = $currentResponse->data; + foreach($employeesPageData as $employee){ + HumanResource::firstOrCreate( + ['ktp_number' => $employee->emp_id], + [ + 'name' => $employee->name, + 'employee_type' => 'employee', + 'status_resource' => 'active', + 'role_id' => 24, + 'created_by' => 'integration' + ], + ); + } + echo "\n------------------------------------------\n"; + $currentResponse = MasterFunctionsHelper::curlReq(str_replace('1', $i, $url)); + } + } +} diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index cdba880..a379d80 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -13,6 +13,7 @@ class Kernel extends ConsoleKernel * @var array */ protected $commands = [ + Commands\syncHumanResourceIntegration::class ]; /** @@ -23,5 +24,7 @@ class Kernel extends ConsoleKernel */ protected function schedule(Schedule $schedule) { - } + $schedule->command('sync:integration-human-resources')->twiceDaily(); + } + }