diff --git a/app/Console/Commands/UpdateNoSjp.php b/app/Console/Commands/UpdateNoSjp.php index 50c690bc..366ddb0c 100644 --- a/app/Console/Commands/UpdateNoSjp.php +++ b/app/Console/Commands/UpdateNoSjp.php @@ -1,6 +1,7 @@ getBody()->getContents(), true); - - $this->info('Jumlah Livechat dikirim: ' . $liveChats->count()); + + LivechatUpdateLog::create([ + 'nIDLivechat' => $row->nID, + 'nIDSummary' => $row->summary_id, + 'status' => 'success', + 'response' => json_encode($body) + ]); + $this->info("Nomor SJP berhasil dibuat untuk Livechat {$row->nID}"); } catch (\Exception $e) { + LivechatUpdateLog::create([ + 'nIDLivechat' => $row->nID, + 'nIDSummary' => $row->summary_id, + 'status' => 'fail', + 'response' => $e->getMessage() + ]); + $this->error("Gagal generate Nomor SJP Livechat {$row->nID}: " . $e->getMessage()); } } diff --git a/app/Models/LivechatUpdateLog.php b/app/Models/LivechatUpdateLog.php new file mode 100644 index 00000000..fb34d6fd --- /dev/null +++ b/app/Models/LivechatUpdateLog.php @@ -0,0 +1,18 @@ +id(); + $table->unsignedBigInteger('nIDLivechat'); + $table->unsignedBigInteger('nIDSummary')->nullable(); + $table->string('status'); + $table->text('response')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('livechat_update_logs'); + } +}; diff --git a/database/seeders/LivechatUpdateLogSeeder.php b/database/seeders/LivechatUpdateLogSeeder.php new file mode 100644 index 00000000..73a886df --- /dev/null +++ b/database/seeders/LivechatUpdateLogSeeder.php @@ -0,0 +1,19 @@ +