fix some bugs from chart
This commit is contained in:
@@ -78,6 +78,53 @@ class CustomerController extends SuperController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* حضور سبک برای چت پشتیبانی: chat_room_id / chat_user_id → last_seen_at
|
||||
* (همان منبع آنلاین بودن صفحهی کاربران آنلاین).
|
||||
*/
|
||||
public function chatPresence()
|
||||
{
|
||||
$hasRoom = \Schema::hasColumn('customers', 'chat_room_id');
|
||||
$hasUser = \Schema::hasColumn('customers', 'chat_user_id');
|
||||
|
||||
if (! $hasRoom && ! $hasUser) {
|
||||
return response()->json([
|
||||
'online_within_seconds' => CustomerPresenceService::ONLINE_THRESHOLD_SECONDS,
|
||||
'rows' => [],
|
||||
]);
|
||||
}
|
||||
|
||||
$columns = ['id', 'last_seen_at'];
|
||||
if ($hasRoom) {
|
||||
$columns[] = 'chat_room_id';
|
||||
}
|
||||
if ($hasUser) {
|
||||
$columns[] = 'chat_user_id';
|
||||
}
|
||||
|
||||
$query = Customer::query()
|
||||
->where('is_archive', false)
|
||||
->select($columns);
|
||||
|
||||
$query->where(function ($q) use ($hasRoom, $hasUser) {
|
||||
if ($hasRoom) {
|
||||
$q->orWhere(function ($inner) {
|
||||
$inner->whereNotNull('chat_room_id')->where('chat_room_id', '!=', '');
|
||||
});
|
||||
}
|
||||
if ($hasUser) {
|
||||
$q->orWhere(function ($inner) {
|
||||
$inner->whereNotNull('chat_user_id')->where('chat_user_id', '!=', '');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return response()->json([
|
||||
'online_within_seconds' => CustomerPresenceService::ONLINE_THRESHOLD_SECONDS,
|
||||
'rows' => $query->get(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateAdmin(Request $request , $id)
|
||||
{
|
||||
$data = $request->all();
|
||||
|
||||
Reference in New Issue
Block a user