user('web'); abort_unless($actor instanceof User, 403); $filter = $request->validate(['view' => 'nullable|in:all,unread,tasks,outcomes', 'page' => 'nullable|integer|min:1|max:100000']); $visible = collect($notices->visible($actor)); $unread = $visible->whereNull('read_at')->count(); $items = ($filter['view'] ?? 'all') === 'unread' ? $visible->whereNull('read_at')->values() : $visible; if (in_array($filter['view'] ?? '', ['tasks', 'outcomes'], true)) { $items = $visible->where('kind', $filter['view'] === 'tasks' ? 'task' : 'outcome')->values(); } $page = (int) ($filter['page'] ?? 1); $response = Inertia::render('workflow/notices', ['ready' => Schema::hasTable('workflow_notices'), 'unread' => $unread, 'view' => $filter['view'] ?? 'all', 'notices' => (new LengthAwarePaginator($items->slice(($page - 1) * 25, 25)->values(), $items->count(), 25, $page, ['path' => $request->url()]))->withQueryString()])->toResponse($request); $response->headers->set('Cache-Control', 'private, no-store, max-age=0'); return $response; } public function read(Request $request, int $notice, WorkflowNotices $notices): Response { $actor = $request->user('web'); abort_unless($actor instanceof User, 403); $notices->read($actor, $notice); return redirect('/requisicoes/avisos'); } public function refresh(Request $request, int $requisition, WorkflowNotices $notices): Response { $actor = $request->user('web'); abort_unless($actor instanceof User, 403); $notices->refresh($actor, $requisition, $request->all()); return redirect('/requisicoes/'.$requisition); } }