@php
use Illuminate\Support\Str;
$user = auth()->user();
if ($user->hasRole('super-admin')) {
$layout = 'layouts.superadmin';
} elseif ($user->hasRole('advisor')) {
$layout = 'layouts.advisor';
} elseif ($user->hasRole('moderator')) {
$layout = 'layouts.moderator';
} else {
$layout = 'layouts.member';
}
$from = $from ?? request('from', '');
$to = $to ?? request('to', '');
$qText = $qText ?? request('q', '');
$presenceLabel = fn($value) => match ((int) $value) {
2 => 'متواجد كل اليوم',
1 => 'متواجد صباح/مساء',
default => 'غير محدد',
};
@endphp
@extends($layout)
@section('title', 'تقييماتي المعتمدة')
@section('content')
{{-- HERO --}}
فقط التقييمات المعتمدة
هنا بتشوف تقييماتك المعتمدة + اسم المقيم (إذا مسموح بإظهار هويته).
ضمن الفلاتر
{{ number_format((int) ($kpis['total'] ?? 0)) }}
{{-- KPIs --}}
@php
$pill = fn($label, $val, $cls) => "
";
@endphp
{!! $pill('متوسط النقاط', $kpis['avg_pts'] ?? '0', 'text-emerald-600') !!}
{!! $pill('الإنذارات', (int) ($kpis['warnings'] ?? 0), 'text-rose-500') !!}
{!! $pill('حاضر', (int) ($kpis['present'] ?? 0), 'text-emerald-600') !!}
{!! $pill('غياب بعذر', (int) ($kpis['excused'] ?? 0), 'text-yellow-500') !!}
{!! $pill('غياب بدون', (int) ($kpis['noexcuse'] ?? 0), 'text-rose-500') !!}
{!! $pill('الإجمالي', (int) ($kpis['total'] ?? 0), 'text-slate-900') !!}
{{-- Filters --}}
{{-- LIST --}}
@if ($evaluations->count())
@foreach ($evaluations as $e)
@php
$date = optional($e->evaluation_date)->format('Y-m-d') ?? '—';
$evaluatorName = 'مقيم مجهول';
if ((int) ($e->show_evaluator_name ?? 0) === 1) {
$evaluatorName = $e->evaluator?->name ?? 'مشرف';
}
$attendanceTxt = match ((string) ($e->attendance_status ?? '')) {
'present' => 'حاضر',
'absent_with_excuse' => 'غائب بعذر',
'absent_without_excuse' => 'غائب بدون عذر',
default => 'غير محدد',
};
$pts = (int) ($e->total_daily_points ?? 0);
$wp = (int) ($e->whatsapp_presence ?? 0);
$tt = (int) ($e->tiktok_interaction ?? 0);
$notes = trim((string) ($e->evaluator_notes ?? ''));
$excuse = trim((string) ($e->excuse_reason ?? ''));
$avatarUrl = asset('images/default-avatar.png'); // الصورة الافتراضية
if ($e->evaluator && $e->evaluator->avatar) {
// لو الرابط كامل خارجي
if (Str::startsWith($e->evaluator->avatar, ['http://', 'https://'])) {
$avatarUrl = $e->evaluator->avatar;
}
// لو الصورة موجودة في storage/app/public
elseif (Storage::disk('public')->exists($e->evaluator->avatar)) {
$avatarUrl = asset('storage/' . $e->evaluator->avatar);
}
// لو الصورة موجودة في public/images
elseif (file_exists(public_path('images/' . $e->evaluator->avatar))) {
$avatarUrl = asset('images/' . $e->evaluator->avatar);
}
}
$wpLabel = $presenceLabel($wp);
$ttLabel = $presenceLabel($tt);
@endphp
المقيم
{{ $evaluatorName }}
{{ $e->evaluator?->username ?? 'مشرف' }}
رقم التقييم
#{{ $e->id }}
{{ $date }}
الحضور
{{ $attendanceTxt }}
@if ($attendanceTxt === 'غائب بعذر' && $excuse !== '')
العذر: {{ $excuse }}
@else
أُقِرّ الحضور وتوقيته من المشرف.
@endif
واتساب
{{ $wp }}
نقطة
{{ $wpLabel }}
تقييم المشرف: {{ $pts > 0 ? '+' : '' }}{{ $pts }}
تيكتوك
{{ $tt }}
{{ $ttLabel }}
الإنذارات: {{ (int) ($e->warnings_count ?? 0) }}
@if ($notes !== '')
ملخص الملاحظات
{{ $notes }}
@endif
@endforeach
{{ $evaluations->links() }}
@else
لا يوجد تقييمات معتمدة ضمن هذه الفلاتر.
@endif
@endsection