taller/resources/views/roles/index.blade.php
2026-10-15 08:51:58 -03:00

88 lines
2.6 KiB
PHP

@extends('layouts.admin')
@section('contenido')
<div class="container">
<h3>Listado de Roles</h3>
<a href="{{ route('roles.create') }}" class="btn btn-success mb-3">
Nuevo Rol
</a>
@if(session('mensaje-success'))
<div class="alert alert-success">
{{ session('mensaje-success') }}
</div>
@endif
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>ID</th>
<th>Nombre</th>
<th>Permisos</th>
<th>Usuarios</th>
<th>Acciones</th>
</tr>
</thead>
<tbody>
@foreach($roles as $rol)
<tr>
<td>{{ $rol->id }}</td>
<td>{{ $rol->name }}</td>
<td>
@forelse($rol->permissions as $permiso)
<span class="badge badge-info">
{{ $permiso->name }}
</span>
@empty
Sin permisos
@endforelse
</td>
<td>
@forelse($rol->usuarios as $usuario)
<span class="badge badge-secondary">
{{ $usuario->name }}
</span>
@empty
Sin usuarios
@endforelse
</td>
<td>
<a href="{{ route('roles.show', $rol->id) }}"
class="btn btn-info btn-sm">
Ver
</a>
<a href="{{ route('roles.edit', $rol->id) }}"
class="btn btn-warning btn-sm">
Editar
</a>
<form action="{{ route('roles.destroy', $rol->id) }}"
method="POST"
style="display:inline;">
@csrf
@method('DELETE')
<button type="submit"
class="btn btn-danger btn-sm"
onclick="return confirm('¿Eliminar rol?')">
Eliminar
</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endsection