@extends('layouts.app')

@section('content')
<div class="container">
    <h2>Gestión de Permisos</h2>

    <a href="{{ route('permissions.create') }}" class="btn btn-primary mb-3">
        Nuevo Permiso
    </a>

    <table class="table table-bordered">
        <thead>
            <tr>
                <th>ID</th>
                <th>Nombre</th>
                <th>Acciones</th>
            </tr>
        </thead>
        <tbody>
            @foreach($permissions as $permission)
            <tr>
                <td>{{ $permission->id }}</td>
                <td>{{ $permission->name }}</td>
                <td>
                    <a href="{{ route('permissions.edit',$permission) }}" 
                       class="btn btn-warning btn-sm">Editar</a>

                    <form action="{{ route('permissions.destroy',$permission) }}" 
                          method="POST" class="d-inline">
                        @csrf @method('DELETE')
                        <button class="btn btn-danger btn-sm"
                          onclick="return confirm('¿Eliminar este permiso?')">
                          Eliminar
                        </button>
                    </form>
                </td>
            </tr>
            @endforeach
        </tbody>
    </table>
</div>
@endsection
