update pagination livechat
This commit is contained in:
@@ -141,8 +141,6 @@ class ChatController extends Controller
|
||||
'type' => 'file',
|
||||
]);
|
||||
}
|
||||
|
||||
$data = Message::where('channel_id', $request->channel_id)->get()->toArray();
|
||||
// Berikan respons yang sesuai ke klien
|
||||
|
||||
$channel = Channel::where('id',$request->channel_id)->first();
|
||||
@@ -162,7 +160,6 @@ class ChatController extends Controller
|
||||
'message' => 'Message sent successfully',
|
||||
'data' => [
|
||||
'header' => $name,
|
||||
'chat' => $data
|
||||
]
|
||||
]);
|
||||
}
|
||||
@@ -216,8 +213,14 @@ class ChatController extends Controller
|
||||
}
|
||||
|
||||
// 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
|
||||
$consultationSummary = [
|
||||
'subject' => $livechat->subject,
|
||||
@@ -230,10 +233,9 @@ class ChatController extends Controller
|
||||
if ($livechat->health_certificate_start && $livechat->health_certificate_end){
|
||||
$healthSertificate = True;
|
||||
}
|
||||
|
||||
// Berikan respons yang sesuai ke klien
|
||||
return response()->json([
|
||||
'message' => 'Message sent successfully',
|
||||
'message' => 'Message sent successfully',
|
||||
'data' => [
|
||||
'header' => $name,
|
||||
'avatar' => $avatar,
|
||||
@@ -244,10 +246,18 @@ class ChatController extends Controller
|
||||
'end' => $consultationEnd,
|
||||
'work' => $work,
|
||||
'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,
|
||||
'livechat_id' => $livechat->id,
|
||||
'health_sertificate' => $healthSertificate
|
||||
'health_sertificate' => $healthSertificate,
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -335,6 +335,12 @@ class DuitkuController extends Controller
|
||||
|
||||
} else if ($notif->resultCode == "01") {
|
||||
// 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']);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,10 @@ namespace Modules\Linksehat\Http\Controllers\Api;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Helpers\DuitkuHelper;
|
||||
use App\Services\Duitku;
|
||||
use App\Models\Organization;
|
||||
use App\Models\PractitionerRole;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\PaymentsMethods;
|
||||
use App\Models\Livechat;
|
||||
use App\Models\OLDLMS\User;
|
||||
@@ -259,7 +261,10 @@ class LivechatController extends Controller
|
||||
|
||||
// Mengambil user dari database
|
||||
$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) {
|
||||
return response()->json(['success' => false, 'message' => 'User not found'], 404);
|
||||
}
|
||||
@@ -270,17 +275,14 @@ class LivechatController extends Controller
|
||||
'paymentAmount' => $totalPay,
|
||||
'email' => $user->sEmail,
|
||||
'phoneNumber' => $user->sPhone,
|
||||
'productDetails' => 'Telekonsul Livechat LMS',
|
||||
'productDetails' => 'INV-' . date('Ymd') . '-' . rand(100, 999),
|
||||
'merchantOrderId' => $livechat->uuid,
|
||||
'additionalParam' => '',
|
||||
'merchantUserInfo' => '',
|
||||
'customerVaName' => $user->sFirstName . ' ' . $user->sLastName,
|
||||
'callbackUrl' => 'https://google.com',
|
||||
'returnUrl' => 'https://linksehat.com',
|
||||
'expiryPeriod' => 60,
|
||||
'firstName' => $user->sFirstName,
|
||||
'lastName' => $user->sLastName,
|
||||
'alamat' => '',
|
||||
'alamat' => $address,
|
||||
'city' => '',
|
||||
'postalCode' => ''
|
||||
];
|
||||
@@ -288,6 +290,7 @@ class LivechatController extends Controller
|
||||
// Membuat invoice menggunakan DuitkuHelper
|
||||
$duitku = DuitkuHelper::createInvoice($data);
|
||||
|
||||
|
||||
return response()->json(['success' => true, 'data' => $duitku], 200);
|
||||
} catch (Exception $e) {
|
||||
// Menangkap error dan mengembalikan respon error
|
||||
|
||||
@@ -93,7 +93,7 @@ class DuitkuHelper
|
||||
$additionalParam = $data['additionalParam']; // optional
|
||||
$merchantUserInfo = $data['merchantUserInfo']; // optional
|
||||
$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
|
||||
$expiryPeriod = 60; // set the expired time in minutes
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ class Duitku
|
||||
$merchantUserInfo = ''; // optional
|
||||
$customerVaName = $patient->name ?? ''; // display name on bank confirmation display
|
||||
$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
|
||||
|
||||
// Customer Detail
|
||||
@@ -53,9 +53,9 @@ class Duitku
|
||||
$lastName = $patient->last_name ?? '';
|
||||
|
||||
// Address
|
||||
$alamat = $patient->address->first()->line ?? '';
|
||||
$alamat = $patient->address?? '';
|
||||
// dd($alamat);
|
||||
$city = $patient->address->first()->city->name ?? '';
|
||||
$city = $patient->city ?? '';
|
||||
// dd($city);
|
||||
$postalCode = $patient->postal_code ?? '';
|
||||
$countryCode = "ID";
|
||||
|
||||
Reference in New Issue
Block a user