23-01-2026

This commit is contained in:
Kevin Adametz 2026-01-23 17:33:10 +01:00
parent 07959c0ba2
commit 854ce02bf6
166 changed files with 32909 additions and 1262 deletions

View file

@ -18,11 +18,14 @@ new class extends Component {
public string $roleIcon = 'shield-check';
public string $roleColor = 'zinc';
public array $rolePermissions = [];
public ?string $regPrefix = null;
public ?string $regDescription = null;
public ?int $regStartNumber = null;
public function with(): array
{
return [
'roles' => Role::with('permissions')->orderBy('name')->get(),
'roles' => Role::with('permissions')->orderBy('id', 'asc')->get(),
'permissions' => Permission::with('roles')->orderBy('name')->get(),
'allPermissions' => Permission::orderBy('name')->get(),
'selectedRole' => $this->selectedRoleId ? Role::find($this->selectedRoleId) : null,
@ -46,6 +49,9 @@ new class extends Component {
$this->roleColor = $role->color ?? 'zinc';
$this->rolePermissions = $role->permissions->pluck('name')->toArray();
$this->roleIcon = $role->icon ?? 'shield-check';
$this->regPrefix = $role->reg_prefix;
$this->regDescription = $role->reg_description;
$this->regStartNumber = $role->reg_start_number;
$this->showEditModal = true;
}
@ -58,6 +64,8 @@ new class extends Component {
$this->validate([
'roleName' => 'required|string|max:255',
'roleColor' => 'required|string|max:50',
'regPrefix' => 'nullable|string|size:1',
'regStartNumber' => 'nullable|integer|min:1',
]);
$role = Role::findOrFail($this->selectedRoleId);
@ -66,12 +74,15 @@ new class extends Component {
'display_name' => $this->roleDisplayName,
'icon' => $this->roleIcon,
'color' => $this->roleColor,
'reg_prefix' => $this->regPrefix,
'reg_description' => $this->regDescription,
'reg_start_number' => $this->regStartNumber,
]);
$role->syncPermissions($this->rolePermissions);
$this->showEditModal = false;
$this->reset(['selectedRoleId', 'roleName', 'roleDisplayName', 'roleIcon', 'roleColor', 'rolePermissions']);
$this->reset(['selectedRoleId', 'roleName', 'roleDisplayName', 'roleIcon', 'roleColor', 'rolePermissions', 'regPrefix', 'regDescription', 'regStartNumber']);
session()->flash('message', __('Role updated successfully!'));
}
@ -79,7 +90,7 @@ new class extends Component {
public function closeEditModal(): void
{
$this->showEditModal = false;
$this->reset(['selectedRoleId', 'roleName', 'roleDisplayName', 'roleIcon', 'roleColor', 'rolePermissions']);
$this->reset(['selectedRoleId', 'roleName', 'roleDisplayName', 'roleIcon', 'roleColor', 'rolePermissions', 'regPrefix', 'regDescription', 'regStartNumber']);
}
}; ?>
@ -90,10 +101,10 @@ new class extends Component {
<flux:heading size="xl" class="mb-2">{{ __('Permissions & Roles Management') }}</flux:heading>
<flux:subheading>{{ __('Manage roles and permissions for your application') }}</flux:subheading>
</div>
<div class="flex gap-2">
{{-- <div class="flex gap-2">
<flux:button variant="primary" icon="plus">{{ __('Create Role') }}</flux:button>
<flux:button variant="ghost" icon="shield-check">{{ __('Create Permission') }}</flux:button>
</div>
</div> --}}
</div>
{{-- Tabs --}}
@ -185,8 +196,7 @@ new class extends Component {
<flux:table.cell>
<div class="flex gap-2">
<flux:button size="sm" variant="ghost" icon="eye"
tooltip="{{ __('View Details') }}"></flux:button>
<flux:button size="sm" variant="ghost" icon="pencil"
wire:click="openEditModal({{ $role->id }})"
tooltip="{{ __('Edit Role') }}"></flux:button>
@ -211,7 +221,7 @@ new class extends Component {
</flux:card>
{{-- Role Statistics --}}
<div class="grid grid-cols-1 gap-6 md:grid-cols-3">
<div class="grid grid-cols-1 gap-6 md:grid-cols-2">
<flux:card class="shadow-elegant">
<div class="flex items-center justify-between">
<div>
@ -236,19 +246,7 @@ new class extends Component {
</div>
</flux:card>
<flux:card class="shadow-elegant">
<div class="flex items-center justify-between">
<div>
<flux:subheading>{{ __('Avg. Permissions/Role') }}</flux:subheading>
<flux:heading size="2xl" class="mt-2">
{{ $roles->count() > 0 ? number_format($roles->sum(fn($r) => $r->permissions->count()) / $roles->count(), 1) : 0 }}
</flux:heading>
</div>
<div class="flex h-12 w-12 items-center justify-center rounded-lg bg-accent-100 dark:bg-accent-900/20">
<flux:icon.chart-bar class="h-6 w-6 text-accent-600 dark:text-accent-400" />
</div>
</div>
</flux:card>
</div>
</div>
@endif
@ -414,6 +412,34 @@ new class extends Component {
</div>
@endif
<flux:separator />
<flux:subheading>{{ __('Registrierungscode-Einstellungen') }}</flux:subheading>
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
<flux:field>
<flux:label>{{ __('Code-Prefix') }}</flux:label>
<flux:input wire:model="regPrefix" maxlength="1" placeholder="z.B. K, M, H" />
<flux:description>{{ __('Einzelner Buchstabe für Registrierungscodes') }}</flux:description>
@error('regPrefix') <flux:error>{{ $message }}</flux:error> @enderror
</flux:field>
<flux:field>
<flux:label>{{ __('Startnummer') }}</flux:label>
<flux:input wire:model="regStartNumber" type="number" placeholder="10000000" />
<flux:description>{{ __('Startnummer für Code-Generierung') }}</flux:description>
@error('regStartNumber') <flux:error>{{ $message }}</flux:error> @enderror
</flux:field>
<flux:field>
<flux:label>{{ __('Beschreibung') }}</flux:label>
<flux:input wire:model="regDescription" placeholder="Code-Beschreibung" />
<flux:description>{{ __('Optionale Beschreibung') }}</flux:description>
</flux:field>
</div>
<flux:separator />
<flux:field>
<flux:label>{{ __('Permissions') }}</flux:label>
<flux:description>{{ __('Select permissions for this role') }}</flux:description>