@php // Per-field error map stashed by the controller on a failed submit, read raw so it can be // indexed by field name — the same shape contact.php and the sign-up form use. $fieldErrors = \App\Support\Session::old('__errors', []); $fieldErrors = is_array($fieldErrors) ? $fieldErrors : []; $err = static function (string $f) use ($fieldErrors, $__env): string { return isset($fieldErrors[$f][0]) ? (string) $fieldErrors[$f][0] : ''; }; @endphp @php /** * Vendor → Branches: consolidated view of every venue this owner runs, with recent takings per * branch, a switch action that re-points the whole dashboard, light grouping, and an "Add branch" * flow that registers another venue through the same pending → admin-approval path as the first one. * * @var array $branches @var array $stats @var array $groups @var array $cuisines @var int $activeRid */ use App\Support\Auth; $isOwner = Auth::is('vendor'); $totalSales = 0.0; $totalOrders = 0; foreach ($branches as $b) { $s = $stats[(int) $b['id']] ?? null; $totalSales += (float) ($s['sales'] ?? 0); $totalOrders += (int) ($s['orders'] ?? 0); } @endphp @php /* Add branch sits in the card head, not the page subhead. This is a Settings PANEL now, and the subhead belongs to the Settings page as a whole — a button pushed there would hang over every other tab. Same placement as "Add tier" on the zones panel. */ @endphp

{{ t_raw('vendor.branches.list_heading') }}

@if ($isOwner) @endif
@foreach ($branches as $b) @php $bid = (int) $b['id']; $s = $stats[$bid] ?? null; $st = (string) ($b['status'] ?? 'approved'); @endphp @endforeach
{{ t_raw('vendor.branches.col_branch') }} {{ t_raw('vendor.branches.col_group') }} {{ t_raw('vendor.branches.col_today_sales') }} {{ t_raw('vendor.branches.col_today_orders') }} {{ t_raw('common.actions') }}
@php /* THE VENUE, READ THE WAY THE PRODUCT READS A VENUE — the same .qm-tbl-id anatomy every restaurant table uses: its mark, then its name with the city under it. An estate of five "Pizza Palace ..." rows is told apart by the logo long before the words are read. No state label here: the action column names it once, where it also explains why there is or is not a button to press. */ @endphp
{!! restaurant_brandmark($b, 'md') !!}
{{ $b['name'] }}@if (!empty($b['city'])){{ (string) $b['city'] }}@endif
@csrf
{{ money((float) ($s['sales'] ?? 0)) }} {{ (int) ($s['orders'] ?? 0) }} @php /* THE ACTION COLUMN SAYS WHAT YOU CAN DO, so it must not offer something that cannot be done. The dashboard only follows an owner into an APPROVED venue -- a pending or suspended one would meet them with the standing wall, which carries no switcher to get back -- so switchBranch() turns those clicks away. Offering "Switch to" anyway meant pressing it did nothing, with no way to tell whether the click had missed or the product had. The venue's own state is named here instead, and the button returns the moment it is approved. */ @endphp @if ($bid === $activeRid){{ t_raw('vendor.branches.current_label') }} @elseif ($st !== 'approved'){{ status_label('restaurant', $st) }} @else
@csrf
@endif
{{ t_raw('vendor.branches.total_label') }} {{ money($totalSales) }} {{ (int) $totalOrders }}

{{ t_raw('vendor.branches.groups_heading') }}

@if ($isOwner)@endif
@if ($isOwner)@endif @if ($groups) @foreach ($groups as $g) @if ($isOwner) @endif @endforeach @else @partial('table-empty', ['colspan' => $isOwner ? 3 : 2, 'icon' => 'fa-layer-group', 'msg' => t_raw('vendor.branches.no_groups')]) @endif
{{ t_raw('vendor.branches.groups_col_name') }} {{ t_raw('vendor.branches.groups_col_branches') }}{{ t_raw('common.actions') }}
{{ $g['name'] }} {{ (int) ($g['branch_count'] ?? 0) }} @partial('row-actions', ['inline' => 0, 'actions' => [ ['label' => t_raw('vendor.branches.rename'), 'icon' => 'fa-pen', 'attrs' => [ 'data-bs-toggle' => 'modal', 'data-bs-target' => '#groupModal', 'data-group-edit' => '1', 'data-id' => (string) (int) $g['id'], 'data-name' => (string) $g['name'], ]], ['label' => t_raw('common.delete'), 'icon' => 'fa-trash-alt', 'danger' => true, 'form' => [ 'action' => '/vendor/branches/group-delete', 'fields' => ['id' => (int) $g['id']], 'confirm' => t_raw('vendor.branches.confirm_delete_group'), ]], ]])
@if ($isOwner) @if (request()->query('add') === '1') @endif @endif