@extends('layouts.dashboard') @section('content') @php /** * Admin → Roles → New / Edit role. Name the role, then pick what it may do. * * @var array|null $role the role being edited, or null when creating * @var array $catalogue config/permissions.php — module => ['label', 'perms'] * @var array $held privilege slugs currently ticked * @var array $pills selectable badge colours * @var int $labelMax max length of the name field * @var int $descMax max length of the description field */ $role = $role ?? null; $catalogue = $catalogue ?? []; $held = $held ?? []; $pills = $pills ?? ['blue']; $isEdit = $role !== null; $curPill = (string) ($role['pill'] ?? ''); if (!in_array($curPill, $pills, true)) { $curPill = $pills[0]; } $total = count(\App\Models\Role::catalogueSlugs()); $chosen = count(array_intersect($held, \App\Models\Role::catalogueSlugs())); @endphp @php /* .qm-d2: the dashboard density standard (app.css §35) */ @endphp
@php // Page-level Back action lives in the subheader band (right of the breadcrumb), not inside the card header. @endphp @php ob_start(); @endphp {{ t_raw('common.back') }} @php \App\Support\View::slot('subhead', ob_get_clean()); @endphp
@csrf

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

{{ t_raw('admin.roles.selected_pill', [':n' => $chosen, ':total' => $total]) }}
@php // The name/description/colour row reuses the app's shared filter-bar component (.qm-order-filters + .qm-of-field/.qm-of-label) — the same responsive labelled-field bar the Orders/Users/Reviews filters use — so it looks and reflows identically instead of a bespoke row/col style. @endphp
@php // Modules tile into our responsive grid (2-up ≥md, 3-up ≥xl) instead of stacking full-width, so the page stays compact. h-100 + mb-0 keep the cards equal-height per row with the gutter, not qm-card's own margin. @endphp
@foreach ($catalogue as $modKey => $module) @php $perms = $module['perms']; $on = count(array_intersect(array_keys($perms), $held)); @endphp

{{ t_raw($module['label']) }}

{{ $on }} / {{ count($perms) }}
@php /* Select-all as a head switch, the same control Clear database wears — its on/off state mirrors "every permission in this module is held". */ @endphp
@foreach ($perms as $slug => $perm) @endforeach
@endforeach
@php /* /.qm-d2 */ @endphp @endsection