{{-- Notice table of Nuheter in Admin (#2957 slice 13, card #3099). Included by notice/adminIndex only (customers see notice/partials/list). Expects: $data (paginator of Notice). Toolbar: the same GET parameters as the old filter box, q (title and content) and hideHidden (1 hides notices that are hidden or past their stop time). Per row, as before: status (the old green or red dot and the start and stop time colours are now one pill: Dold, UtgƄngen, Kommande or Synlig), the type word for global and welcome notices, the title with "ny" while the admin has not read it, the period, the company (link to the company, "Alla" for global notices), the creator and when it was created. The title opens notice.show as before (admin.notice.show 500s for notices of deleted companies, #3111); "Redigera" opens admin.notice.edit. --}} @php $data->appends(request()->except('page')); $query = (string) request('q', ''); $hideHidden = request('hideHidden') == 1; $now = \Carbon\Carbon::now(); // One query for the page: which of these notices the admin has read (as Notice::readByUser()). $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(); $time = fn ($value) => $value ? \App\Support\DisplayDate::timestamp($value) : null; @endphp @if ($data->isEmpty()) {{ __('notice.nh.admin.emptyText') }} @if ($query !== '' || $hideHidden) {{ __('notice.nh.admin.showAll') }} @endif @else @foreach ($data as $notice) @php $stop = $notice->stop_time; [$pill, $word] = match (true) { $notice->status == 0 => ['stopped', __('notice.nh.admin.hidden')], $stop && $stop->lt($now) => ['stopped', __('notice.nh.admin.expired')], $notice->start_time && $notice->start_time->gt($now) => ['planned', __('notice.nh.admin.upcoming')], default => ['done', __('notice.nh.admin.visible')], }; $type = [1 => __('notice.nh.admin.typeGlobal'), 2 => __('notice.nh.admin.typeWelcome')][$notice->type] ?? null; @endphp @endforeach
{{ __('notice.nh.admin.columnNotice') }} {{ __('notice.nh.admin.columnPeriod') }} {{ __('notice.nh.admin.columnCompany') }} {{ __('notice.nh.admin.columnCreated') }} {{ __('notice.nh.admin.columnActions') }}
{{ $notice->title }} {{ $word }} @if ($type){{ $type }}@endif @if ($notice->prio == 10){{ __('notice.nh.important') }}@endif @unless ($readIds->has((int) $notice->id)){{ __('notice.new') }}@endunless @if ($stop){{ $time($notice->start_time) }} {{ __('notice.nh.admin.periodTo') }} {{ $time($stop) }}@else{{ __('notice.nh.admin.from', ['start' => $time($notice->start_time)]) }}@endif @if (is_null($notice->company_id)) {{ __('notice.index.allCompanies') }} @elseif (! is_null($notice->company)) {{ $notice->company->name }} @else - @endif {{ $time($notice->created_at) }}@if ($notice->user){{ $notice->user->username }}@endif @can('noticeEdit') {{ __('notice.nh.admin.edit') }} @endcan
{{ trans_choice('notice.nh.admin.count', $data->total(), ['count' => formatNumber($data->total())]) }}
@endif