From 1eb6eb9cf369d07fbb84748e992d8616f407130b Mon Sep 17 00:00:00 2001 From: Tb Fajri Date: Mon, 3 Jun 2024 11:09:51 +0700 Subject: [PATCH] imporve first message --- .../Http/Controllers/Api/DuitkuController.php | 15 +++++++-- ...4_add_device_id_to_notification_tokens.php | 32 +++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 database/migrations/2024_06_03_094814_add_device_id_to_notification_tokens.php diff --git a/Modules/Linksehat/Http/Controllers/Api/DuitkuController.php b/Modules/Linksehat/Http/Controllers/Api/DuitkuController.php index 8a9be088..b361a590 100644 --- a/Modules/Linksehat/Http/Controllers/Api/DuitkuController.php +++ b/Modules/Linksehat/Http/Controllers/Api/DuitkuController.php @@ -8,6 +8,7 @@ use App\Models\Organization; use App\Models\Speciality; use App\Models\Livechat; use App\Models\Channel; +use App\Models\Message; use App\Models\UserChannel; use App\Models\User as UserAso; use App\Models\OLDLMS\User; @@ -277,7 +278,8 @@ class DuitkuController extends Controller header('Content-Type: application/json'); $notif = json_decode($callback); - // $notif = $request; ini untuk di local + // $notif = $request; //ini untuk di local + // $callback = $notif; //ini untuk di local DB::table('api_logs') ->insert([ @@ -298,7 +300,6 @@ class DuitkuController extends Controller $livechat->start_date = date('Y-m-d H:i:s'); $livechat->save(); - // Send Notification $doctorId = $livechat->doctor_id; $userDokter = UserAso::where('person_id',$doctorId)->first(); @@ -314,6 +315,16 @@ class DuitkuController extends Controller 'livechat_id' => (string) $livechat->id, 'type' => 'success-payment' ]; + + $question = $livechat->descriptions; + // Ambil data dari request + $message = Message::create([ + 'content' => $question, + 'from_user' => $livechat->patient_id, + 'channel_id' => $channel->id, + 'type' => 'first_chat' + ]); + $userDokter->notify(new SendNotification($title, $body, $dataNotif)); $patient->notify(new SendNotification($title, $body, $dataNotif)); diff --git a/database/migrations/2024_06_03_094814_add_device_id_to_notification_tokens.php b/database/migrations/2024_06_03_094814_add_device_id_to_notification_tokens.php new file mode 100644 index 00000000..aef86b88 --- /dev/null +++ b/database/migrations/2024_06_03_094814_add_device_id_to_notification_tokens.php @@ -0,0 +1,32 @@ +string('device_id')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('notification_tokens', function (Blueprint $table) { + $table->dropColumn('device_id'); + }); + } +};