@extends('layouts.dashboard') @section('content') @php /** * Push notifications — shared by the admin (platform) and vendor (own-staff) * dashboards. $scope decides the audience options and the endpoints. * Reuses the .qm-card / .qm-table / .modal patterns; no new styles. * * @var string $scope 'platform' | 'restaurant' * @var array $rows * @var array $pager * @var array $audiences selectable audience keys for this scope * @var string $baseUrl '/admin/push-notifications' | '/vendor/push-notifications' * @var array|null $form carried-back input after a validation error */ $rows = $rows ?? []; $audiences = $audiences ?? []; $form = $form ?? null; // Human label for an audience key. Platform 'staff' = all staff; a restaurant // send's 'staff' is the vendor's own team, so it reads "My staff". $audienceLabel = static function (string $scope, string $aud): string { if ($scope === 'restaurant') { // 'staff' is the whole team; any other value is one staff role (kitchen, host, …). return $aud === 'staff' ? t_raw('push.aud_my_staff') : role_label($aud); } return t_raw('push.aud_' . $aud); }; @endphp @php // Page primary action -> top-bar subheader slot, like every sibling list page. ob_start(); @endphp @php \App\Support\View::slot('subhead', ob_get_clean()); @endphp

{{ t_raw('push.list_heading') }}

{!! $scope === 'restaurant' ? t('push.sub_vendor') : t('push.sub_admin') !!}

@php /* Sent carries no data-sort: it renders a date *and* a time, which the sorter's Date.parse() cannot read, so offering the control would sort it wrongly. */ @endphp @if (count($rows)) @foreach ($rows as $b) @endforeach @else @partial('table-empty', ['colspan' => 5, 'icon' => 'fa-bullhorn', 'msg' => t('push.empty')]) @endif
{{ t_raw('push.th_title') }} {{ t_raw('push.th_audience') }} {{ t_raw('push.th_recipients') }} {{ t_raw('push.th_sent') }} {{ t_raw('common.actions') }}
{{ (string) $b['title'] }} @if (!empty($b['body']))
{{ (string) $b['body'] }}
@endif
{!! $audienceLabel($scope, (string) $b['audience']) !!} {{ number_format((int) $b['recipient_count']) }} {!! fmt_datetime($b['last_sent_at']) !!} @if ((int) $b['send_count'] > 1){{ t_raw('push.sent_times', [':count' => (int) $b['send_count']]) }}@endif
@csrf
@partial('table-toolbar', ['pager' => $pager, 'base' => $baseUrl])
@php // Compose modal — Title, Send to, Message, Send / Close (reuses the .modal pattern). @endphp @if ($form) @endif @endsection