Module
Add
View
Update
Delete
@php
$actions = ['add','view','update','delete'];
$actionAliases = [
'add' => ['add','create','store'],
'view' => ['view','index','show'],
'update' => ['update','edit'],
'delete' => ['delete','destroy'],
];
$normalize = fn($v) => strtolower(str_replace(['-','.','_'],'',$v));
@endphp
{{ str_replace('-', ' ', $module) }}
@foreach($actions as $action)
@php
$permissionName = null;
$moduleVariants = [$module, \Illuminate\Support\Str::plural($module)];
foreach ($perms as $perm) {
$permNorm = $normalize($perm);
foreach ($moduleVariants as $mod) {
$modNorm = $normalize($mod);
if (!str_contains($permNorm, $modNorm)) continue;
foreach ($actionAliases[$action] as $alias) {
if (str_contains($permNorm, $normalize($alias))) {
$permissionName = $perm;
break 3;
}
}
if (
$action === 'view' &&
($permNorm === $modNorm || str_ends_with($perm, '.index'))
) {
$permissionName = $perm;
break 2;
}
}
}
@endphp
@if($permissionName)
@endif
@endforeach
{{-- Data Scope --}}
@php
$scope = $roleScopes[$module] ?? ['scope_type' => 'all', 'scope_value' => []];
@endphp
@endforeach