Gestión de usuarios por proyecto: ProjectUsers Livewire, AdminUsers, panel admin con roles, protección de rutas

This commit is contained in:
2026-05-09 23:32:22 +02:00
parent 3e8b6f1eb3
commit 2cb10b0854
10 changed files with 312 additions and 3 deletions
@@ -0,0 +1,53 @@
<div>
@if(session()->has('message'))
<div class="alert alert-success mb-2 text-sm">{{ session('message') }}</div>
@endif
@if(session()->has('error'))
<div class="alert alert-error mb-2 text-sm">{{ session('error') }}</div>
@endif
<div class="overflow-x-auto">
<table class="table table-zebra w-full">
<thead>
<tr>
<th>{{ __('Name') }}</th>
<th>{{ __('Email') }}</th>
<th>{{ __('Role') }}</th>
<th>{{ __('Language') }}</th>
<th>{{ __('Actions') }}</th>
</tr>
</thead>
<tbody>
@foreach($users as $user)
<tr>
<td class="font-medium">{{ $user->name }}</td>
<td class="text-sm">{{ $user->email }}</td>
<td>
<div class="flex flex-wrap gap-1">
@foreach($user->roles as $role)
<span class="badge badge-sm {{ $role->name === 'Admin' ? 'badge-error' : 'badge-primary' }}">
{{ __($role->name) }}
</span>
@endforeach
</div>
</td>
<td class="text-sm">{{ strtoupper($user->locale ?? 'en') }}</td>
<td>
@can('assign users')
<select wire:change="updateRole({{ $user->id }}, $event.target.value)"
class="select select-bordered select-xs"
@if(Auth::id() === $user->id && $user->hasRole('Admin')) disabled @endif>
@foreach($roles as $role)
<option value="{{ $role->name }}" @selected($user->hasRole($role->name))>
{{ __($role->name) }}
</option>
@endforeach
</select>
@endcan
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>