@extends('admin.layout.template') @section('title','Add Role') @section('content')
@csrf {{-- Role Info --}}

Create Role

{{-- Permissions --}} @foreach($permissions as $module => $perms)

{{ ucfirst($module) }}

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); // module must match if (!str_contains($permNorm, $modNorm)) continue; // action must match (with aliases) foreach ($actionAliases[$action] as $alias) { if (str_contains($permNorm, $normalize($alias))) { $permissionName = $perm; break 3; } } // VIEW special case: permission == module or module.index if ( $action === 'view' && ( $permNorm === $modNorm || \Illuminate\Support\Str::endsWith($perm, '.index') ) ) { $permissionName = $perm; break 2; } } } @endphp
@if($permissionName) @endif
@endforeach
@endforeach
@endsection