@extends('layouts.dashboard') @section('content') @php /** * Admin → Roles. What each role in the platform may do, and how many accounts hold it. * * @var array $roles role rows in display order * @var array $permCounts role id => privileges held * @var array $userCounts role slug => live accounts */ $roles = $roles ?? []; $permCounts = $permCounts ?? []; $userCounts = $userCounts ?? []; $catalogueTotal = count(\App\Models\Role::catalogueSlugs()); @endphp @php /* .qm-d2: the dashboard density standard (app.css §35) */ @endphp
@php // Page primary action → top-bar subheader slot (leaves the table card header for the // title + any table-scoped utility). ob_start captures the button HTML for the layout slot. ob_start(); @endphp {{ t_raw('admin.roles.new_btn') }} @php \App\Support\View::slot('subhead', ob_get_clean()); @endphp

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

{{ t_raw('admin.roles.total_pill', [':count' => count($roles)]) }}
@foreach ($roles as $r) @php $rid = (int) $r['id']; $slug = (string) $r['slug']; $staff = ($r['scope'] ?? '') === 'staff'; $system = (int) ($r['is_system'] ?? 0) === 1; $perms = (int) ($permCounts[$rid] ?? 0); $users = (int) ($userCounts[$slug] ?? 0); // A platform identity holds what owning its data implies, so its privilege // count is the whole catalogue rather than a stored list. $shown = $staff ? $perms : ($slug === 'super_admin' || $slug === 'vendor' ? $catalogueTotal : 0); @endphp @endforeach
{{ t_raw('admin.roles.col_role') }} {{ t_raw('admin.roles.col_permissions') }} {{ t_raw('admin.roles.col_users') }} {{ t_raw('common.actions') }}
{{ role_label($slug) }} @if (!empty($r['description'])){{ $r['description'] }}@endif
{!! role_pill($slug) !!} @if ($system){{ t_raw('admin.roles.pill_system') }}@endif
@if ($staff) {{ number_format($shown) }} @elseif ($shown > 0) {{ number_format($shown) }} @else {!! dash() !!} @endif @if ($users > 0) {{ number_format($users) }} @else{!! dash() !!}@endif @php $rowActions = [ $staff ? [ 'label' => t_raw('common.edit'), 'icon' => 'fa-pen', 'href' => '/admin/roles/' . $rid, 'primary' => true, ] : [ // Nothing to grant or revoke on a platform identity, so the row // says so rather than offering a control that does nothing. 'label' => t_raw('admin.roles.action_structural'), 'icon' => 'fa-lock', 'primary' => true, 'disabled' => true, ], $system ? null : [ 'label' => t_raw('common.delete'), 'icon' => 'fa-trash-alt', 'danger' => true, 'form' => [ 'action' => '/admin/roles/delete', 'fields' => ['id' => $rid], 'confirm' => t_raw('admin.roles.confirm_delete', [':name' => role_label($slug)]), ], ], ]; @endphp @partial('row-actions', ['actions' => array_values(array_filter($rowActions))])
@php /* /.qm-d2 */ @endphp @endsection