
@extends('layouts.app')
@section('title','Roles')
@section('content')

<div class="page-header">
    <div class="page-block">
        <div class="row align-items-center">
            <div class="col-md-12">
                <div class="d-flex justify-content-between">
                    <div>
                        <div class="page-header-title">
                            <h5>Roles</h5>
                        </div>
                        <ul class="breadcrumb">
                            <li class="breadcrumb-item"><a href="{{ route('home') }}"><i class="feather icon-home"></i></a></li>
                            <li class="breadcrumb-item"><a href="#!">Configuración</a></li>
                            <li class="breadcrumb-item"><a href="#!">Roles</a></li>
                        </ul>
                    </div>
                    @can('roles.create')
                        <a href="{{ route('roles.create') }}" class="btn btn-primary btn-round">Agregar Nuevo</a>
                    @endif
                </div>
            </div>
        </div>
    </div>
</div>
<div class="row">
    <div class="col-lg-8">
        <div class="card">
            <div class="card-header">
                <div class="d-flex align-items-center justify-content-between">
                    <h4>Listado de roles registrados</h4>
                    
                </div> 
            </div>
            <div class="card-body table-border-style">
                <div class="table-responsive">
                    <table class="table table-hover table-sm">
                        <thead>
                            <tr>
                                <th class="text-center">Rol</th>
                                <th class="text-center ">Descripción</th>
                                <th class="text-center" >Acciones</th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach($roles as $role)
                                <tr>
                                    <td class="fw-bold">{{$role->name}}</td>
                                    <td class="text-wrap">{{$role->descripcion}}</td>
                                    <td>
                                        <div class="d-flex justify-content-center">
                                            @can('roles.show')
                                                <a href="{{route('roles.show',$role->id)}}" ><button class="btn btn-secondary btn-icon btn-round" title="Ver los permisos asignados al rol"><i class="fas fa-eye"></i></button></a>
                                            @endcan
                                            @can('roles.edit')
                                                <a href="{{route('roles.edit',$role->id)}}"  ><button class="btn btn-warning btn-icon btn-round" title="Modificar Permisos asignados al rol"><i class="fas fa-edit"></i></button></a>
                                            @endcan
                                            @can('roles.destroy')
                                                <form action="{{ route('roles.destroy',$role->id) }}" method="POST" >
                                                    @csrf @method('DELETE')
                                                    <button class="btn btn-danger btn-icon btn-round " data-toggle="tooltip" data-placement="top" title="Eliminar rol" onclick="return confirm('¿Está seguro que desea eliminar el rol?');"><i class="fas fa-trash-alt"></i></button>
                                                </form>
                                            @endcan
                                        </div>
                                    </td>
                                </tr>
                            @endforeach
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
 @endsection