added last seen 2

This commit is contained in:
2026-07-22 17:37:33 +03:30
parent 692c211ca8
commit 5751e2cd24
2 changed files with 24 additions and 0 deletions
@@ -14,6 +14,7 @@ use App\Models\Setting;
use App\Services\AssetSummaryService;
use App\Services\BalanceReportService;
use App\Services\ConfigService;
use App\Services\CustomerPresenceService;
use App\Services\ReferralGiftService;
use App\Services\WalletBalanceService;
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
@@ -54,6 +55,28 @@ class CustomerController extends SuperController
return response()->json($users);
}
/**
* مشتریان با SSE فعال در بازهٔ آنلاین بودن (last_seen_at تازه).
*/
public function onlineList()
{
$threshold = now()->subSeconds(CustomerPresenceService::ONLINE_THRESHOLD_SECONDS);
$rows = Customer::query()
->where('is_archive', false)
->whereNotNull('last_seen_at')
->where('last_seen_at', '>=', $threshold)
->orderByDesc('last_seen_at')
->get(['id', 'name', 'mobile', 'last_seen_at', 'active', 'trade_active', 'type']);
return response()->json([
'count' => $rows->count(),
'online_within_seconds' => CustomerPresenceService::ONLINE_THRESHOLD_SECONDS,
'rows' => $rows,
]);
}
public function updateAdmin(Request $request , $id)
{
$data = $request->all();
+1
View File
@@ -91,6 +91,7 @@ Route::middleware('auth:user')->group(function (){
//--------customer
Route::post('/customer/table',[CustomerController::class,'tableWallets']);
Route::get('/customer/online',[CustomerController::class,'onlineList']);
Route::get('/customer/{id}/assets',[CustomerController::class,'assetsSummary']);
Route::get('/customer/active/{id}',[CustomerController::class,'active']);
Route::get('/customer/archive/{id}',[CustomerController::class,'archive']);