{{-- Notice rows of Nuheter (#2957 slice 6e, card #3020). Included by notice/index only (admins list notices with notice/partials/adminList on the old layout). Expects: $data (paginator of Notice), $showRead (whether read notices are included). Per row, as before the reskin: the title links to notice.show, "ny" while unread, the high priority marker (prio 10, now a pill with a word), the first 150 characters of the content as plain text, when it was published, and "Markera som läst" while unread: a CSRF POST to notice.markAsRead that redirects back to this list (#3086). The button sits outside its hidden form so the row actions keep their layout. --}} @php $data->appends(request()->except('page')); // One query for the whole page: which of these notices the current user has read // (the same notice_user rows Notice::readByUser() checks, without loading every reader). $readIds = $data->isEmpty() ? collect() : \Illuminate\Support\Facades\DB::table('notice_user') ->where('user_id', Auth::id()) ->whereIn('notice_id', $data->pluck('id')) ->pluck('notice_id') ->map(fn ($id) => (int) $id) ->flip(); @endphp {{ __('notice.nh.columnNotice') }}{{ __('notice.nh.columnPublished') }}{{ __('notice.nh.columnActions') }} @foreach ($data as $notice) @php $unread = ! $readIds->has((int) $notice->id); $excerpt = str_limit(strip_tags($notice->content), 150); @endphp {{ $notice->title }} @if ($unread || $notice->prio == 10) @if ($notice->prio == 10) {{ __('notice.nh.important') }} @endif @if ($unread) {{ __('notice.new') }} @endif @endif @if ($excerpt !== '') {{ $excerpt }} @endif {{ __('notice.nh.open') }} @if ($unread) {{ __('notice.markAsRead') }} @endif @endforeach {{ trans_choice($showRead ? 'notice.nh.countAll' : 'notice.nh.countUnread', $data->total(), ['count' => formatNumber($data->total())]) }}