fix private channel
This commit is contained in:
@@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Linksehat\Http\Controllers\Api\Doctor;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Models\Livechat;
|
||||||
|
use Crypt;
|
||||||
|
use Error;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
use Modules\Internal\Emails\SendVerifyEmail;
|
||||||
|
use Modules\Internal\Events\ForgetPassword;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Modules\HospitalPortal\Helpers\ApiResponse;
|
||||||
|
use App\Helpers\Helper;
|
||||||
|
use Illuminate\Support\Facades\View;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class ChatDoctorController extends Controller
|
||||||
|
{
|
||||||
|
public function getChat()
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
'user_id' => auth()->check() ? auth()->user()->id : null,
|
||||||
|
];
|
||||||
|
$user_id = auth()->check() ? auth()->user()->id : null;
|
||||||
|
//Get data Chat
|
||||||
|
$user = User::where('id',$user_id)->with('person')->first();
|
||||||
|
$chat = Livechat::where([
|
||||||
|
'doctor_id'=> $user->person_id,
|
||||||
|
'accept_date'=> null,
|
||||||
|
])->get()->toArray();
|
||||||
|
dd($chat);
|
||||||
|
|
||||||
|
return ApiResponse::apiResponse("Success", $res_data, trans('Message.success'), 200);
|
||||||
|
|
||||||
|
}
|
||||||
|
public function fWorkExperience($start, $end)
|
||||||
|
{
|
||||||
|
$startDateString = $start; // Tanggal dan waktu awal
|
||||||
|
$endDateString = $end ; // Tanggal dan waktu akhir
|
||||||
|
|
||||||
|
// Mengubah string tanggal ke timestamp UNIX
|
||||||
|
$startTime = strtotime($startDateString);
|
||||||
|
$endTime = strtotime($endDateString);
|
||||||
|
|
||||||
|
// Menghitung selisih waktu dalam detik
|
||||||
|
$timeDifference = $endTime - $startTime;
|
||||||
|
|
||||||
|
// Menghitung jumlah tahun, bulan, dan hari dari selisih waktu
|
||||||
|
$years = floor($timeDifference / (365 * 24 * 60 * 60));
|
||||||
|
$months = floor(($timeDifference - ($years * 365 * 24 * 60 * 60)) / (30 * 24 * 60 * 60));
|
||||||
|
$days = floor(($timeDifference - ($years * 365 * 24 * 60 * 60) - ($months * 30 * 24 * 60 * 60)) / (24 * 60 * 60));
|
||||||
|
|
||||||
|
// Formatkan hasilnya
|
||||||
|
$experience = '';
|
||||||
|
if ($years > 0) {
|
||||||
|
$experience .= $years . ' years ';
|
||||||
|
}
|
||||||
|
if ($months > 0) {
|
||||||
|
$experience .= $months . ' months ';
|
||||||
|
}
|
||||||
|
if ($days > 0) {
|
||||||
|
$experience .= $days . ' days';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $experience;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,6 +20,7 @@ use Modules\Linksehat\Http\Middleware\Doctor\Authentication;
|
|||||||
use Modules\Linksehat\Http\Middleware\Doctor\Authorization;
|
use Modules\Linksehat\Http\Middleware\Doctor\Authorization;
|
||||||
use Modules\Linksehat\Http\Controllers\Api\Doctor\AuthDoctorController;
|
use Modules\Linksehat\Http\Controllers\Api\Doctor\AuthDoctorController;
|
||||||
use Modules\Linksehat\Http\Controllers\Api\Doctor\ProfileDoctorController;
|
use Modules\Linksehat\Http\Controllers\Api\Doctor\ProfileDoctorController;
|
||||||
|
use Modules\Linksehat\Http\Controllers\Api\Doctor\ChatDoctorController;
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| API Routes
|
| API Routes
|
||||||
@@ -139,6 +140,9 @@ Route::prefix('linksehat')->group(function () {
|
|||||||
Route::controller(ProfileDoctorController::class)->group(function () {
|
Route::controller(ProfileDoctorController::class)->group(function () {
|
||||||
Route::get('get-profile', 'getProfile');
|
Route::get('get-profile', 'getProfile');
|
||||||
});
|
});
|
||||||
|
Route::controller(ChatDoctorController::class)->group(function () {
|
||||||
|
Route::get('chat', 'getChat');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
Route::controller(AuthDoctorController::class)->group(function () {
|
Route::controller(AuthDoctorController::class)->group(function () {
|
||||||
@@ -147,6 +151,7 @@ Route::prefix('linksehat')->group(function () {
|
|||||||
Route::post('resend-code', 'forgotPassword');
|
Route::post('resend-code', 'forgotPassword');
|
||||||
Route::post('reset-password', 'resetPassword');
|
Route::post('reset-password', 'resetPassword');
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
;});
|
;});
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Broadcast;
|
use Illuminate\Support\Facades\Broadcast;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Models\Channel;
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Broadcast Channels
|
| Broadcast Channels
|
||||||
@@ -13,10 +15,10 @@ use Illuminate\Support\Facades\Broadcast;
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Broadcast::channel('App.Models.User.{id}', function ($user, $id) {
|
Broadcast::channel('App.Models.User.{id}', function ($user, $id) {
|
||||||
// return (int) $user->id === (int) $id;
|
return (int) $user->id === (int) $id;
|
||||||
// });
|
});
|
||||||
|
|
||||||
Broadcast::channel('chat.{id}', function ($user, $id) {
|
Broadcast::channel('chat.{room_id}', function ($user, $room_id) {
|
||||||
return true;
|
return Auth::check();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user