@extends('layouts.superadmin') @section('title','مراقبة الرسائل — ProSanta') @section('content') @php use Illuminate\Support\Str; use Illuminate\Support\Carbon; $fromVal = request('from', isset($from) ? (is_string($from) ? $from : $from->toDateString()) : now()->subDays(14)->toDateString()); $toVal = request('to', isset($to) ? (is_string($to) ? $to : $to->toDateString()) : now()->toDateString()); // ✅ $messages لازم تكون موجودة (Pagination) $rows = $messages ?? collect(); // ✅ $flagsMap keyBy('message_id') من الكنترولر $flagsMap = $flagsMap ?? collect(); // ===== احصائيات من الصفحة الحالية (فورية) ===== $totalOnPage = method_exists($rows,'count') ? $rows->count() : 0; $flaggedOnPage = 0; $critOnPage = 0; $highOnPage = 0; $openOnPage = 0; // توزيع أنواع $typeCounts = []; $sevCounts = ['low'=>0,'medium'=>0,'high'=>0,'critical'=>0]; $statusCounts = ['open'=>0,'reviewed'=>0,'closed'=>0,'false_positive'=>0]; if(method_exists($rows,'getCollection')) { foreach ($rows->getCollection() as $m) { $f = $flagsMap[$m->id] ?? null; if($f){ $flaggedOnPage++; $sev = strtolower((string)($f->severity ?? 'low')); $st = strtolower((string)($f->status ?? 'open')); $pt = (string)($f->primary_type ?? $f->flag_type ?? 'unknown'); if(isset($sevCounts[$sev])) $sevCounts[$sev]++; else $sevCounts['low']++; if(isset($statusCounts[$st])) $statusCounts[$st]++; else $statusCounts['open']++; if($sev === 'critical') $critOnPage++; if($sev === 'high') $highOnPage++; if($st === 'open') $openOnPage++; $typeCounts[$pt] = ($typeCounts[$pt] ?? 0) + 1; } } } // Top types (لـ charts) arsort($typeCounts); $topTypes = array_slice($typeCounts, 0, 8, true); // AI tips (مبسطة لكنها فعالة) $aiTips = []; if($critOnPage > 0){ $aiTips[] = "يوجد {$critOnPage} حالة حرجة في هذه الصفحة — الأفضل مراجعتها أولًا."; } if(($typeCounts['passwords'] ?? 0) > 0 || ($typeCounts['password'] ?? 0) > 0){ $aiTips[] = "تم رصد مؤشرات على كلمات مرور — فعّل تنبيه توعوي للأعضاء بعدم مشاركة بيانات الدخول."; } if(($typeCounts['otp'] ?? 0) > 0){ $aiTips[] = "ظهرت أكواد تحقق/OTP — اقترح إخفاء الأرقام تلقائيًا داخل الرسائل."; } if(!$aiTips){ $aiTips[] = "الوضع مستقر ضمن الصفحة الحالية. تابع الحالات المفتوحة فقط."; } // Helper badges $sevBadge = function($sev){ $sev = strtolower($sev ?: 'low'); return match($sev){ 'critical' => 'bg-rose-500/15 border-rose-400/25 text-rose-200', 'high' => 'bg-amber-500/15 border-amber-400/25 text-amber-200', 'medium' => 'bg-cyan-500/12 border-cyan-400/20 text-cyan-200', default => 'bg-white/5 border-white/10 text-white/75', }; }; $statusBadge = function($st){ $st = strtolower($st ?: 'open'); return match($st){ 'open' => 'bg-rose-500/12 border-rose-400/20 text-rose-200', 'reviewed' => 'bg-amber-500/12 border-amber-400/20 text-amber-200', 'closed' => 'bg-emerald-500/12 border-emerald-400/20 text-emerald-200', 'false_positive' => 'bg-slate-500/12 border-white/10 text-white/70', default => 'bg-white/5 border-white/10 text-white/75', }; }; @endphp
لوحة ملحمية لمراقبة الرسائل، الحالات الحساسة/الممنوعات، وإحصائيات سريعة — مع أدوات مراجعة واتخاذ قرار.
الممنوعات تظهر كبادج + مقتطف آمن.
| # | من | إلى | الموضوع | مقتطف | ممنوعات | التاريخ |
|---|---|---|---|---|---|---|
| #{{ $m->id }} | {{ $m->sender->name ?? ('User#'.$m->sender_id) }} | {{ $m->receiver->name ?? ('User#'.$m->receiver_id) }} |
{{ $m->subject ?? '(بدون موضوع)' }}
|
{{ Str::limit($m->body ?? '', 90) }} |
@if($f)
{{ strtoupper($f->severity) }}
{{ strtoupper($f->status) }}
{{ $f->primary_type ?? $f->flag_type ?? 'flag' }}
@else
—
@endif
|
{{ optional($m->created_at)->format('Y-m-d H:i') }} |
| لا توجد بيانات ضمن هذه الفلاتر. | ||||||