@extends('layouts.app') @php $editing = $role->exists; $groups = \App\Support\Permissions::groups(); $actions = ['view' => 'View', 'create' => 'Create', 'edit' => 'Edit', 'delete' => 'Delete']; // groups that have the full view / create / edit / delete set are shown as a grid, everything else as single switches $matrixGroups = collect($groups)->filter(fn ($g, $key) => isset($g['permissions']["$key.delete"])); $matrixKeys = $matrixGroups->flatMap(fn ($g, $key) => collect(array_keys($actions))->map(fn ($a) => "$key.$a"))->all(); $selected = old('permissions', $role->permissions ?? []); $total = count(\App\Support\Permissions::all()); @endphp @section('title', $editing ? 'Edit '.$role->name : 'New role') @section('content')
@csrf @if ($editing) @method('PUT') @endif @include('partials.error-summary')
@php($scope = old('data_scope', $role->data_scope ?: 'own'))
{{ $errors->first('data_scope') }}
What they can do with records
Create, edit and delete automatically include View.
0 of {{ $total }}
@foreach ($actions as $label)@endforeach @foreach ($matrixGroups as $key => $group) @foreach ($actions as $a => $label) @php($perm = "$key.$a") @endforeach @endforeach
Records{{ $label }}All
{{ $group['label'] }}
Other access
    @foreach ($groups as $key => $group) @foreach ($group['permissions'] as $perm => [$label, $desc]) @continue(in_array($perm, $matrixKeys, true))
  • @endforeach @endforeach
Cancel Unsaved changes
@endsection