@extends('admin.layouts.layout')
@section('content')
    <section>
        <div class="row match-height">
            <div class="col-md-12 col-12">
                <div class="card">
                    <div class="card-header">
                        <h4 class="card-title text-primary">Usuários</h4>
                        <small class="text-muted">Cadastro dos Usuários no Sistema</small>
                    </div>
                    <div class="card-body">

                        <a class="btn btn-outline-primary btn-sm w-100" type="button" href="{{ route('usuarios.create') }}"
                            role="button">Novo Usuário</a>
                    </div>
                    <div class="card-content">
                        <div class="card-body">

                            <!-- Table -->
                            <div class="table-responsive">
                                <table class="table table-sm table-hover">
                                    <thead>
                                        <tr>
                                            <th scope="col">Código</th>
                                            <th scope="col">Nome</th>
                                            <th scope="col">e-Mail</th>
                                            <th scope="col">Admin</th>
                                            <th scope="col">Ações</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        @foreach ($usuarios as $usuario)
                                            <tr>
                                                <td scope="row">{{ $usuario->id }}</td>
                                                <td scope="row">{{ $usuario->name }}</td>
                                                <td scope="row">{{ $usuario->email }}</td>
                                                <td scope="row">{{ $usuario->admin }}</td>
                                                <td>
                                                    <a href="{{ route('usuarios.edit', $usuario->id) }}"
                                                        class="btn btn-sm btn-outline-warning">Editar</a>

                                                    <form class="d-inline" method="POST"
                                                        action="{{ route('usuarios.destroy', $usuario->id) }}"
                                                        onSubmit="return confirm('Tem certeza que deseja excluir?')">
                                                        @method('DELETE')
                                                        @csrf
                                                        <button class="btn btn-sm btn-outline-danger">Exluir</button>
                                                    </form>

                                                </td>
                                            </tr>
                                        @endforeach

                                    </tbody>
                                </table>
                            </div>
                            {{ $usuarios->links('pagination::bootstrap-4') }}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    @endsection
