@extends('layouts.login.theme')
@section('title', env('APP_NAME').' :: '.__('Eventos'))
@section('content')
<section class="container">
    @include('errors.messageFlash')
    <div class="d-flex justify-content-between align-items-center mb-3">
        <h5 class="text-white">Eventos</h5>
        <a href="{{ route('admin.eventos.create') }}" class="btn btn-primary">Novo evento</a>
    </div>
    <div class="card-admin-login p-4">
        <table class="table table-dark table-striped">
            <thead>
                <tr>
                    <th>Título</th>
                    <th>Secretaria</th>
                    <th>Início</th>
                    <th>Status</th>
                    <th>Ações</th>
                </tr>
            </thead>
            <tbody>
                @foreach($eventos as $evento)
                <tr>
                    <td>{{ $evento->titulo }}</td>
                    <td>{{ optional($evento->secretaria)->name }}</td>
                    <td>{{ \Carbon\Carbon::parse($evento->data_inicio)->format('d/m/Y H:i') }}</td>
                    <td>{{ $evento->status }}</td>
                    <td>
                        <a href="{{ route('admin.eventos.edit', $evento->id) }}" class="btn btn-sm btn-warning">Editar</a>
                        <form action="{{ route('admin.eventos.destroy', $evento->id) }}" method="POST" style="display:inline-block">
                            @csrf
                            @method('DELETE')
                            <button type="submit" class="btn btn-sm btn-danger" onclick="return confirm('Excluir este evento?')">Excluir</button>
                        </form>
                        <form action="{{ route('admin.eventos.status', $evento->id) }}" method="POST" style="display:inline-block">
                            @csrf
                            <button type="submit" class="btn btn-sm btn-secondary">Alternar Status</button>
                        </form>
                    </td>
                </tr>
                @endforeach
            </tbody>
        </table>
        {{ $eventos->links() }}
    </div>
 </section>
@endsection

