tambah table log update np sjp
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\LivechatUpdateLog;
|
||||
use App\Models\OLDLMS\Livechat;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
@@ -32,11 +33,24 @@ class UpdateNoSJP extends Command {
|
||||
]);
|
||||
|
||||
$body = json_decode($response->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());
|
||||
}
|
||||
}
|
||||
|
||||
18
app/Models/LivechatUpdateLog.php
Normal file
18
app/Models/LivechatUpdateLog.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class LivechatUpdateLog extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'nIDLivechat',
|
||||
'nIDSummary',
|
||||
'status',
|
||||
'response'
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('livechat_update_logs', function (Blueprint $table) {
|
||||
$table->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');
|
||||
}
|
||||
};
|
||||
19
database/seeders/LivechatUpdateLogSeeder.php
Normal file
19
database/seeders/LivechatUpdateLogSeeder.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class LivechatUpdateLogSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user