update send notification fcm
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace Modules\Linksehat\Http\Controllers\Api\Doctor;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Notifications\SendNotification;
|
||||
use App\Models\User;
|
||||
use App\Models\OLDLMS\User as UserLMS;
|
||||
use App\Models\Livechat;
|
||||
@@ -132,6 +133,34 @@ class ChatDoctorController extends Controller
|
||||
$livechat->status = 3; // Decline
|
||||
// Menyimpan perubahan ke database
|
||||
$livechat->save();
|
||||
|
||||
// Send Notification
|
||||
$doctorId = $livechat->doctor_id;
|
||||
$title = 'Decline Livechat';
|
||||
$body = 'Decline Livechat';
|
||||
$channel = Channel::where([
|
||||
'member_id' => $livechat->patient_id,
|
||||
'doctor_id' => $livechat->doctor_id
|
||||
])->first();
|
||||
$dataNotif = [
|
||||
'channel_id' => $channel->id,
|
||||
'livechat_id' => $livechat->id,
|
||||
'type' => 'decline-chat'
|
||||
];
|
||||
|
||||
$user = UserLMS::where('nID',$livechat->patient_id)->first();
|
||||
if ($user) {
|
||||
$user->notify(new SendNotification($title, $body, $dataNotif));
|
||||
return ApiResponse::apiResponse("Success",['message' => 'Livechat updated successfully'], trans('Message.success'), 200);
|
||||
} else {
|
||||
return Helper::responseJson(
|
||||
status: 'Not Found',
|
||||
statusCode: 404,
|
||||
message: 'Doctor not found.'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return ApiResponse::apiResponse("Success",['message' => 'Livechat updated successfully'], trans('Message.success'), 200);
|
||||
} else {
|
||||
return response()->json(['message' => 'Livechat not found'], 404);
|
||||
@@ -147,7 +176,34 @@ class ChatDoctorController extends Controller
|
||||
$livechat->accept_date = date('Y-m-d H:i:s'); // Accept
|
||||
// Menyimpan perubahan ke database
|
||||
$livechat->save();
|
||||
return ApiResponse::apiResponse("Success",['message' => 'Livechat updated successfully'], trans('Message.success'), 200);
|
||||
|
||||
// Send Notification
|
||||
$doctorId = $livechat->doctor_id;
|
||||
$title = 'Approve Request Livechat';
|
||||
$body = 'Approve Livechat';
|
||||
$channel = Channel::where([
|
||||
'member_id' => $livechat->patient_id,
|
||||
'doctor_id' => $livechat->doctor_id
|
||||
])->first();
|
||||
$dataNotif = [
|
||||
'channel_id' => $channel->id,
|
||||
'livechat_id' => $livechat->id,
|
||||
'type' => 'approve-chat'
|
||||
];
|
||||
|
||||
$user = UserLMS::where('nID',$livechat->patient_id)->first();
|
||||
|
||||
if ($user) {
|
||||
$user->notify(new SendNotification($title, $body, $dataNotif));
|
||||
return ApiResponse::apiResponse("Success",['message' => 'Livechat updated successfully'], trans('Message.success'), 200);
|
||||
} else {
|
||||
return Helper::responseJson(
|
||||
status: 'Not Found',
|
||||
statusCode: 404,
|
||||
message: 'Doctor not found.'
|
||||
);
|
||||
}
|
||||
|
||||
} else {
|
||||
return response()->json(['message' => 'Livechat not found'], 404);
|
||||
}
|
||||
@@ -159,10 +215,36 @@ class ChatDoctorController extends Controller
|
||||
if ($livechat) {
|
||||
// Memperbarui atribut model
|
||||
$livechat->status = 6; // End Chat
|
||||
$livechat->end_date = date('Y-m-d H:i:s'); // Accept
|
||||
$livechat->end_date = date('Y-m-d H:i:s'); // Endchat
|
||||
// Menyimpan perubahan ke database
|
||||
$livechat->save();
|
||||
return ApiResponse::apiResponse("Success",['message' => 'Livechat updated successfully'], trans('Message.success'), 200);
|
||||
|
||||
// Send Notification
|
||||
$doctorId = $livechat->doctor_id;
|
||||
$title = 'End Livechat';
|
||||
$body = 'End Livechat';
|
||||
$channel = Channel::where([
|
||||
'member_id' => $livechat->patient_id,
|
||||
'doctor_id' => $livechat->doctor_id
|
||||
])->first();
|
||||
$dataNotif = [
|
||||
'channel_id' => $channel->id,
|
||||
'livechat_id' => $livechat->id,
|
||||
'type' => 'end-chat'
|
||||
];
|
||||
|
||||
$user = UserLMS::where('nID',$livechat->patient_id)->first();
|
||||
|
||||
if ($user) {
|
||||
$user->notify(new SendNotification($title, $body, $dataNotif));
|
||||
return ApiResponse::apiResponse("Success",['message' => 'Livechat updated successfully'], trans('Message.success'), 200);
|
||||
} else {
|
||||
return Helper::responseJson(
|
||||
status: 'Not Found',
|
||||
statusCode: 404,
|
||||
message: 'Doctor not found.'
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return response()->json(['message' => 'Livechat not found'], 404);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user