@extends('layouts.dashboard') @section('content') @php /** * @var array $rows posts on this page * @var array $pager paginate() metadata * @var int $queued posts waiting on a schedule, across every page * @var bool $cronOn is the publish_scheduled task switched on */ $queued = (int) ($queued ?? 0); $cronOn = (bool) ($cronOn ?? false); // A draft carrying a publish_at is scheduled; one whose moment has already passed is waiting // on the next tick and says so, rather than claiming a time it did not keep. $scheduleOf = static function (array $b): string { if (($b['status'] ?? '') !== 'draft' || empty($b['publish_at'])) { return ''; } return strtotime((string) $b['publish_at']) > time() ? 'scheduled' : 'due'; }; @endphp @php /* .qm-d2: the dashboard density standard (app.css §35) */ @endphp

{{ t_raw('admin.blog.list_heading') }}

{{ t_raw('admin.blog.new_post') }}
@php /* A scheduled post only goes live if the task that publishes it is running. Saying so here — and only when something is actually waiting — is the difference between a backlog and a silent one. */ @endphp @if ($queued > 0 && !$cronOn)
{{ t_raw('admin.blog.schedule_off_title', [':n' => $queued]) }}

{{ t_raw('admin.blog.schedule_off_text') }} {{ t_raw('admin.blog.schedule_off_link') }}

@endif
@if ($rows) @foreach ($rows as $b) @php $sched = $scheduleOf($b); @endphp @php /* Published posts date from when they went live; a scheduled one shows the moment it is waiting for, so the column always answers "when is/was this public?" rather than going blank for half the list. */ @endphp @php $when = $sched !== '' ? (string) $b['publish_at'] : (string) $b['published_at']; @endphp @endforeach @else @partial('table-empty', ['colspan' => 5, 'icon' => 'fa-newspaper', 'msg' => t('admin.blog.empty')]) @endif
{{ t_raw('common.title') }}{{ t_raw('admin.blog.category_label') }}{{ t_raw('common.status') }}{{ t_raw('admin.blog.col_published_date') }}{{ t_raw('common.actions') }}
{{ $b['title'] }}
{{ $b['category_name'] ?? '-' }} @if ($sched === 'scheduled') {{ t_raw('admin.blog.status_scheduled') }} @elseif ($sched === 'due') {{ t_raw('admin.blog.status_publishing') }} @else {!! $b['status'] === 'published' ? t('common.status_published') : t('common.status_draft') !!} @endif {!! $sched !== '' ? fmt_datetime($when) : fmt_day($b['published_at']) !!} @if ($b['status'] === 'published') @else @endif
@csrf
@partial('table-toolbar', ['pager' => $pager, 'base' => '/admin/blog'])
@php /* /.qm-d2 */ @endphp @endsection