update message summary

This commit is contained in:
2024-06-10 10:00:46 +07:00
parent 36ca4925d9
commit 8956d8c13f
4 changed files with 57 additions and 2 deletions

View File

@@ -26,6 +26,7 @@ use Illuminate\Support\Facades\View;
use Illuminate\Support\Facades\DB;
use Kreait\Firebase\Messaging\CloudMessage;
use Kreait\Laravel\Firebase\Facades\Firebase;
use App\Events\ChatMessageSent;
class ChatDoctorController extends Controller
{
@@ -249,6 +250,14 @@ class ChatDoctorController extends Controller
$user = UserLMS::where('nID',$livechat->patient_id)->first();
// Ambil Send End Chat
$message = Message::create([
'content' => 'end-chat',
'from_user' => $livechat->doctor_id,
'channel_id' => $channel->id,
'type' => 'end-chat'
]);
if ($user) {
if ($user->nIDUser) { // Jika Dependent yang request
$user = UserLMS::where('nIDUser',$livechat->patient_id)->first();
@@ -287,6 +296,7 @@ class ChatDoctorController extends Controller
'organization_id' => $livechat->organization_id,
]);
$prescriptionItem = [];
if ($request->prescriptions) {
foreach ($request->prescriptions as $prescription) {
$prescriptionItem = PrescriptionItem::create([
@@ -299,6 +309,27 @@ class ChatDoctorController extends Controller
}
}
$channel = Channel::where([
'member_id' => $livechat->patient_id,
'doctor_id' => $livechat->doctor_id
])->first();
$data = [
'livechat' => $livechat,
'prescription_items' => $prescriptionItem
];
// Ambil data dari request
$message = Message::create([
'content' => 'summary',
'from_user' => $livechat->doctor_id,
'channel_id' => $channel->id,
'type' => 'summary'
]);
ChatMessageSent::dispatch($message);
return ApiResponse::apiResponse("Success",['message' => 'Livechat updated successfully'], trans('Message.success'), 200);
} else {
return response()->json(['message' => 'Livechat not found'], 404);