update pagination livechat
This commit is contained in:
@@ -141,8 +141,6 @@ class ChatController extends Controller
|
|||||||
'type' => 'file',
|
'type' => 'file',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = Message::where('channel_id', $request->channel_id)->get()->toArray();
|
|
||||||
// Berikan respons yang sesuai ke klien
|
// Berikan respons yang sesuai ke klien
|
||||||
|
|
||||||
$channel = Channel::where('id',$request->channel_id)->first();
|
$channel = Channel::where('id',$request->channel_id)->first();
|
||||||
@@ -162,7 +160,6 @@ class ChatController extends Controller
|
|||||||
'message' => 'Message sent successfully',
|
'message' => 'Message sent successfully',
|
||||||
'data' => [
|
'data' => [
|
||||||
'header' => $name,
|
'header' => $name,
|
||||||
'chat' => $data
|
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -216,8 +213,14 @@ class ChatController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ini Untul Chat
|
// Ini Untul Chat
|
||||||
$data = Message::where('channel_id', $request->channel_id)->get()->toArray();
|
$perPage = $request->input('per_page', 10); // Default 10 pesan per halaman
|
||||||
|
$page = $request->input('page', 1); // Default halaman 1
|
||||||
|
|
||||||
|
$data = Message::where('channel_id', $request->channel_id)
|
||||||
|
->where('type', '!=', 'trigger')
|
||||||
|
->orderBy('created_at', 'desc') // Urutkan berdasarkan created_at secara descending
|
||||||
|
->paginate($perPage, ['*'], 'page', $page);
|
||||||
|
|
||||||
// Data Consultation Summary
|
// Data Consultation Summary
|
||||||
$consultationSummary = [
|
$consultationSummary = [
|
||||||
'subject' => $livechat->subject,
|
'subject' => $livechat->subject,
|
||||||
@@ -230,10 +233,9 @@ class ChatController extends Controller
|
|||||||
if ($livechat->health_certificate_start && $livechat->health_certificate_end){
|
if ($livechat->health_certificate_start && $livechat->health_certificate_end){
|
||||||
$healthSertificate = True;
|
$healthSertificate = True;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Berikan respons yang sesuai ke klien
|
// Berikan respons yang sesuai ke klien
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'message' => 'Message sent successfully',
|
'message' => 'Message sent successfully',
|
||||||
'data' => [
|
'data' => [
|
||||||
'header' => $name,
|
'header' => $name,
|
||||||
'avatar' => $avatar,
|
'avatar' => $avatar,
|
||||||
@@ -244,10 +246,18 @@ class ChatController extends Controller
|
|||||||
'end' => $consultationEnd,
|
'end' => $consultationEnd,
|
||||||
'work' => $work,
|
'work' => $work,
|
||||||
'address' => $address,
|
'address' => $address,
|
||||||
'chat' => $data,
|
'chat' => $data->items(),
|
||||||
|
'pagination' => [
|
||||||
|
'total' => $data->total(),
|
||||||
|
'per_page' => $data->perPage(),
|
||||||
|
'current_page' => $data->currentPage(),
|
||||||
|
'last_page' => $data->lastPage(),
|
||||||
|
'from' => $data->firstItem(),
|
||||||
|
'to' => $data->lastItem(),
|
||||||
|
],
|
||||||
'summary' => $consultationSummary,
|
'summary' => $consultationSummary,
|
||||||
'livechat_id' => $livechat->id,
|
'livechat_id' => $livechat->id,
|
||||||
'health_sertificate' => $healthSertificate
|
'health_sertificate' => $healthSertificate,
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -335,6 +335,12 @@ class DuitkuController extends Controller
|
|||||||
|
|
||||||
} else if ($notif->resultCode == "01") {
|
} else if ($notif->resultCode == "01") {
|
||||||
// Action Failed
|
// Action Failed
|
||||||
|
$livechat = Livechat::where('uuid', $notif->merchantOrderId)->first();
|
||||||
|
// Update status pembayaran
|
||||||
|
$livechat->payment_method = $notif->paymentCode;
|
||||||
|
$livechat->status = 7; // failed payment
|
||||||
|
$livechat->save();
|
||||||
|
|
||||||
return response()->json(['message' => 'User Gagal melakukan pembayaran']);
|
return response()->json(['message' => 'User Gagal melakukan pembayaran']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,10 @@ namespace Modules\Linksehat\Http\Controllers\Api;
|
|||||||
|
|
||||||
use App\Helpers\Helper;
|
use App\Helpers\Helper;
|
||||||
use App\Helpers\DuitkuHelper;
|
use App\Helpers\DuitkuHelper;
|
||||||
|
use App\Services\Duitku;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Models\PractitionerRole;
|
use App\Models\PractitionerRole;
|
||||||
|
use App\Models\Invoice;
|
||||||
use App\Models\PaymentsMethods;
|
use App\Models\PaymentsMethods;
|
||||||
use App\Models\Livechat;
|
use App\Models\Livechat;
|
||||||
use App\Models\OLDLMS\User;
|
use App\Models\OLDLMS\User;
|
||||||
@@ -259,7 +261,10 @@ class LivechatController extends Controller
|
|||||||
|
|
||||||
// Mengambil user dari database
|
// Mengambil user dari database
|
||||||
$user = User::with('detail')->where('nId', $livechat->patient_id)->first();
|
$user = User::with('detail')->where('nId', $livechat->patient_id)->first();
|
||||||
|
$address = DB::connection('oldlms')->table('tm_users_address')->where('nIDUser', $user->nID)->first('sAlamat');
|
||||||
|
if($address){
|
||||||
|
$address = $address->sAlamat;
|
||||||
|
}
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
return response()->json(['success' => false, 'message' => 'User not found'], 404);
|
return response()->json(['success' => false, 'message' => 'User not found'], 404);
|
||||||
}
|
}
|
||||||
@@ -270,17 +275,14 @@ class LivechatController extends Controller
|
|||||||
'paymentAmount' => $totalPay,
|
'paymentAmount' => $totalPay,
|
||||||
'email' => $user->sEmail,
|
'email' => $user->sEmail,
|
||||||
'phoneNumber' => $user->sPhone,
|
'phoneNumber' => $user->sPhone,
|
||||||
'productDetails' => 'Telekonsul Livechat LMS',
|
'productDetails' => 'INV-' . date('Ymd') . '-' . rand(100, 999),
|
||||||
'merchantOrderId' => $livechat->uuid,
|
'merchantOrderId' => $livechat->uuid,
|
||||||
'additionalParam' => '',
|
'additionalParam' => '',
|
||||||
'merchantUserInfo' => '',
|
'merchantUserInfo' => '',
|
||||||
'customerVaName' => $user->sFirstName . ' ' . $user->sLastName,
|
'customerVaName' => $user->sFirstName . ' ' . $user->sLastName,
|
||||||
'callbackUrl' => 'https://google.com',
|
|
||||||
'returnUrl' => 'https://linksehat.com',
|
|
||||||
'expiryPeriod' => 60,
|
|
||||||
'firstName' => $user->sFirstName,
|
'firstName' => $user->sFirstName,
|
||||||
'lastName' => $user->sLastName,
|
'lastName' => $user->sLastName,
|
||||||
'alamat' => '',
|
'alamat' => $address,
|
||||||
'city' => '',
|
'city' => '',
|
||||||
'postalCode' => ''
|
'postalCode' => ''
|
||||||
];
|
];
|
||||||
@@ -288,6 +290,7 @@ class LivechatController extends Controller
|
|||||||
// Membuat invoice menggunakan DuitkuHelper
|
// Membuat invoice menggunakan DuitkuHelper
|
||||||
$duitku = DuitkuHelper::createInvoice($data);
|
$duitku = DuitkuHelper::createInvoice($data);
|
||||||
|
|
||||||
|
|
||||||
return response()->json(['success' => true, 'data' => $duitku], 200);
|
return response()->json(['success' => true, 'data' => $duitku], 200);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
// Menangkap error dan mengembalikan respon error
|
// Menangkap error dan mengembalikan respon error
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ class DuitkuHelper
|
|||||||
$additionalParam = $data['additionalParam']; // optional
|
$additionalParam = $data['additionalParam']; // optional
|
||||||
$merchantUserInfo = $data['merchantUserInfo']; // optional
|
$merchantUserInfo = $data['merchantUserInfo']; // optional
|
||||||
$customerVaName = $data['customerVaName']; // display name on bank confirmation display
|
$customerVaName = $data['customerVaName']; // display name on bank confirmation display
|
||||||
$callbackUrl = env('APP_URL').'/api/linksehat/callback-duitku'; // url for callback
|
$callbackUrl = env('DUITKU_PAYMENT_CALLBACK_URL'); // url for callback
|
||||||
$returnUrl = env('APP_URL').'/api/linksehat/redirect-duitku';; // url for redirect
|
$returnUrl = env('APP_URL').'/api/linksehat/redirect-duitku';; // url for redirect
|
||||||
$expiryPeriod = 60; // set the expired time in minutes
|
$expiryPeriod = 60; // set the expired time in minutes
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class Duitku
|
|||||||
$merchantUserInfo = ''; // optional
|
$merchantUserInfo = ''; // optional
|
||||||
$customerVaName = $patient->name ?? ''; // display name on bank confirmation display
|
$customerVaName = $patient->name ?? ''; // display name on bank confirmation display
|
||||||
$callbackUrl = env('DUITKU_PAYMENT_CALLBACK_URL'); // url for callback
|
$callbackUrl = env('DUITKU_PAYMENT_CALLBACK_URL'); // url for callback
|
||||||
$returnUrl = 'https://dev-superapp.primaya.id';
|
$returnUrl = env('');
|
||||||
$expiryPeriod = $paymentMethods->timeout; // set the expired time in minutes
|
$expiryPeriod = $paymentMethods->timeout; // set the expired time in minutes
|
||||||
|
|
||||||
// Customer Detail
|
// Customer Detail
|
||||||
@@ -53,9 +53,9 @@ class Duitku
|
|||||||
$lastName = $patient->last_name ?? '';
|
$lastName = $patient->last_name ?? '';
|
||||||
|
|
||||||
// Address
|
// Address
|
||||||
$alamat = $patient->address->first()->line ?? '';
|
$alamat = $patient->address?? '';
|
||||||
// dd($alamat);
|
// dd($alamat);
|
||||||
$city = $patient->address->first()->city->name ?? '';
|
$city = $patient->city ?? '';
|
||||||
// dd($city);
|
// dd($city);
|
||||||
$postalCode = $patient->postal_code ?? '';
|
$postalCode = $patient->postal_code ?? '';
|
||||||
$countryCode = "ID";
|
$countryCode = "ID";
|
||||||
|
|||||||
Reference in New Issue
Block a user