@auth @php $surveyModal = null; try { $u = auth()->user(); // === Helpers داخل Blade (بدون use statements) === $matchesTargets = function($survey) use ($u) { $targets = \App\Models\SocraticSurveyTarget::where('survey_id', $survey->id)->get(); if ($targets->isEmpty()) return true; if ($targets->where('target_type','all')->count() > 0) return true; foreach ($targets as $t) { if ($t->target_type === 'user' && (string)$u->id === (string)$t->target_value) return true; if ($t->target_type === 'membership_status' && (string)($u->membership_status ?? '') === (string)$t->target_value) return true; if ($t->target_type === 'gender' && (string)($u->gender ?? '') === (string)$t->target_value) return true; // role (spatie) if ($t->target_type === 'role' && $t->target_value && method_exists($u,'hasRole')) { try { if ($u->hasRole($t->target_value)) return true; } catch(\Throwable $e){} } } return false; }; $alreadySubmitted = function($survey) use ($u) { // إذا allow_multiple_submissions = 1 => ما في منع if ((int)($survey->allow_multiple_submissions ?? 0) === 1) return false; // نفس منطق الكنترولر $key = null; if ((int)($survey->is_anonymous ?? 0) === 1) { $anon = hash_hmac('sha256', (string)$u->id, config('app.key')); $key = 'anon:' . $anon . ':survey:' . $survey->id; } else { $key = 'user:' . $u->id . ':survey:' . $survey->id; } return \App\Models\SocraticSurveySubmission::where('survey_id', $survey->id) ->where('submission_key', $key) ->exists(); }; // ✅ جيب أحدث استطلاع Active ويكون مفتوح الآن ومناسب لهدفه ولسه ما انعمل $candidates = \App\Models\SocraticSurvey::query() ->where('status','active') ->orderByDesc('id') ->get(); foreach ($candidates as $s) { if (!$s->isOpenNow()) continue; if (!$matchesTargets($s)) continue; if ($alreadySubmitted($s)) continue; $surveyModal = \App\Models\SocraticSurvey::query() ->where('id', $s->id) ->with(['questions' => function($q){ $q->where('is_active', true) ->orderBy('sort_order') ->with(['options' => function($o){ $o->where('is_active', true)->orderBy('sort_order'); }]); }]) ->first(); break; } } catch (\Throwable $e) { $surveyModal = null; } // ✅ Daily Reading (Widget) $dailyReading = \App\Models\DailyReading::activeForToday()->first(); $hasRead = false; if ($dailyReading && auth()->check()) { $hasRead = $dailyReading->readers() ->where('user_id', auth()->id()) ->exists(); } @endphp @if($surveyModal) @include('surveys.partials.active-modal', ['survey' => $surveyModal]) @endif @include('partials.site-updates-slider') {{-- Redirect to pending site updates (إن وجد) --}} {{-- =========================== | ✅ GLOBAL UI UPGRADE (CSS) |=========================== --}} {{-- =========================== | ✅ DAILY READING (NEW UI) |=========================== --}} @if($dailyReading && !$hasRead)
بنقرة الزر أدناه، أنت تؤكد:
"موافق، قرأت وأقسم بالله أني قرأته بالكامل."