añadir funicionalidades de permisos y grupos
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled

This commit is contained in:
2025-04-27 23:43:22 +02:00
parent fa7c92bee2
commit 883daf32ed
51 changed files with 2673 additions and 441 deletions

View File

@@ -0,0 +1,43 @@
{{-- resources/views/roles/create.blade.php --}}
<x-layouts.app :title="__('Create Roles')">
<div class="container mx-auto px-4 py-8">
<div class="bg-white rounded-lg shadow-md p-6">
<h1 class="text-2xl font-semibold mb-6">Crear Nuevo Rol</h1>
<form action="{{ route('roles.store') }}" method="POST">
@csrf
<div class="mb-4">
<label class="block text-gray-700 text-sm font-bold mb-2">Nombre</label>
<input type="text" name="name"
class="form-input w-full @error('name') border-red-500 @enderror"
required>
@error('name')
<p class="text-red-500 text-xs mt-1">{{ $message }}</p>
@enderror
</div>
<div class="mb-4">
<label class="block text-gray-700 text-sm font-bold mb-2">Permisos</label>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
@foreach($permissions as $permission)
<label class="flex items-center space-x-2">
<input type="checkbox" name="permissions[]"
value="{{ $permission->name }}"
class="form-checkbox">
<span class="text-sm text-gray-700">{{ $permission->name }}</span>
</label>
@endforeach
</div>
</div>
<div class="flex justify-end">
<button type="submit" class="btn-primary">
Crear Rol
</button>
</div>
</form>
</div>
</div>
</x-layouts.app>

View File

@@ -0,0 +1,82 @@
<x-layouts.app :title="__('Roles')">
<div class="container mx-auto px-4 py-8">
<div class="bg-white rounded-lg shadow-md p-6">
<div class="flex justify-between items-center mb-6">
<h1 class="text-2xl font-semibold text-gray-800">Gestión de Roles</h1>
@can('create roles')
<a href="{{ route('roles.create') }}" class="btn-primary">
Nuevo Rol
</a>
@endcan
</div>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Nombre</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Permisos</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Usuarios</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Acciones</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
@forelse($roles as $role)
<tr>
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm font-medium text-gray-900">{{ $role->name }}</div>
<div class="text-sm text-gray-500">{{ $role->description }}</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
@foreach($role->permissions->take(3) as $permission)
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-blue-100 text-blue-800">
{{ $permission->name }}
</span>
@endforeach
@if($role->permissions->count() > 3)
<span class="text-xs text-gray-500">+{{ $role->permissions->count() - 3 }} más</span>
@endif
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
{{ $role->users_count }} usuarios
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
@can('edit roles')
<a href="{{ route('roles.edit', $role) }}" class="text-indigo-600 hover:text-indigo-900 mr-4">
Editar
</a>
@endcan
@can('delete roles')
<form action="{{ route('roles.destroy', $role) }}" method="POST" class="inline">
@csrf
@method('DELETE')
<button type="submit" class="text-red-600 hover:text-red-900"
onclick="return confirm('¿Estás seguro de eliminar este rol?')">
Eliminar
</button>
</form>
@endcan
</td>
</tr>
@empty
<tr>
<td colspan="4" class="px-6 py-4 text-center text-gray-500">
No hay roles registrados
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
@if($roles->hasPages())
<div class="mt-6">
{{ $roles->links() }}
</div>
@endif
</div>
</div>
</x-layouts.app>