bugs fix livechat
This commit is contained in:
@@ -21,7 +21,7 @@ use Illuminate\Support\Facades\Http;
|
||||
use Modules\Linksehat\Transformers\Livechat\LivechatResource;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Http\Controllers\DuitkuController;
|
||||
|
||||
use App\Models\UserChannel;
|
||||
use DB;
|
||||
use Illuminate\Contracts\Filesystem\Cloud;
|
||||
use Kreait\Firebase\Messaging\CloudMessage;
|
||||
@@ -156,7 +156,6 @@ class LivechatController extends Controller
|
||||
* Status Livechat
|
||||
* 1=Request, 2=Accept, 3=Decline, 4=Waiting Payment, 5=Success Payment, 6 = End Chat, 7=Payment Failed
|
||||
*/
|
||||
|
||||
$timezone = date_default_timezone_get();
|
||||
$data['request_date'] = date('Y-m-d H:i:s');
|
||||
$data['timezone'] = $timezone;
|
||||
@@ -171,19 +170,55 @@ class LivechatController extends Controller
|
||||
'image_path' => 'https' // Ganti dengan path yang benar jika ada
|
||||
];
|
||||
|
||||
// Buat dan simpan data channel ke dalam tabel
|
||||
$channel = Channel::updateOrCreate([
|
||||
'member_id' => $livechat->patient_id,
|
||||
'doctor_id' => $livechat->doctor_id,
|
||||
],
|
||||
[
|
||||
'name' => $livechat->patient_id .'_' . $livechat->doctor_id,
|
||||
'type' => 'Private',
|
||||
'member_id' => $livechat->patient_id,
|
||||
'doctor_id' => $livechat->doctor_id,
|
||||
]);
|
||||
|
||||
// Menggunakan updateOrCreate untuk menambahkan data UserChannel untuk member_id
|
||||
UserChannel::updateOrCreate(
|
||||
[
|
||||
'user_id' => $livechat->patient_id,
|
||||
'channel_id' => $channel->id
|
||||
],
|
||||
[
|
||||
'user_id' => $livechat->patient_id,
|
||||
'channel_id' => $channel->id
|
||||
]
|
||||
);
|
||||
|
||||
// Menggunakan updateOrCreate untuk menambahkan data UserChannel untuk doctor_id
|
||||
UserChannel::updateOrCreate(
|
||||
[
|
||||
'user_id' => $livechat->doctor_id,
|
||||
'channel_id' => $channel->id
|
||||
],
|
||||
[
|
||||
'user_id' => $livechat->doctor_id,
|
||||
'channel_id' => $channel->id
|
||||
]
|
||||
);
|
||||
|
||||
// Send Notification
|
||||
$doctorId = $livechat->doctor_id;
|
||||
$user = UserAso::find($doctorId);
|
||||
$user = UserAso::where('person_id',$doctorId)->first();
|
||||
$title = 'New Request Livechat';
|
||||
$patient = User::where('nID', $livechat->patient_id)->first();
|
||||
$body = 'Request Livechat from ' . $patient->sFirstName . ' ' . $patient->sLastName;
|
||||
$channel = Channel::where([
|
||||
'member_id' => $livechat->patient_id,
|
||||
'doctor_id' => $livechat->doctor_id
|
||||
])->first();
|
||||
// $channel = Channel::where([
|
||||
// 'member_id' => $livechat->patient_id,
|
||||
// 'doctor_id' => $livechat->doctor_id
|
||||
// ])->first();
|
||||
$dataNotif = [
|
||||
'channel_id' => $channel->id,
|
||||
'livechat_id' => $livechat->id,
|
||||
'channel_id' => (string) $channel->id,
|
||||
'livechat_id' => (string) $livechat->id,
|
||||
'type' => 'request-chat'
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user