@extends('layouts.login.theme')
@section('title', env('APP_NAME').' :: '.__('Editar Evento'))
@section('content')
<section class="container">
    @include('errors.messageFlash')
    <div class="card-admin-login p-4">
        <form action="{{ route('admin.eventos.update', $evento->id) }}" method="POST">
            @csrf
            @method('PUT')
            <div class="mb-3">
                <label class="form-label">Título</label>
                <input type="text" name="titulo" class="form-control" value="{{ old('titulo', $evento->titulo) }}" required>
            </div>
            <div class="mb-3">
                <label class="form-label">Descrição</label>
                <textarea name="descricao" class="form-control" rows="4">{{ old('descricao', $evento->descricao) }}</textarea>
            </div>
            <div class="row">
                <div class="col-md-6 mb-3">
                    <label class="form-label">Data início</label>
                    <input type="datetime-local" name="data_inicio" class="form-control" value="{{ old('data_inicio', \Carbon\Carbon::parse($evento->data_inicio)->format('Y-m-d\TH:i')) }}" required>
                </div>
                <div class="col-md-6 mb-3">
                    <label class="form-label">Data fim</label>
                    <input type="datetime-local" name="data_fim" class="form-control" value="{{ old('data_fim', $evento->data_fim ? \Carbon\Carbon::parse($evento->data_fim)->format('Y-m-d\TH:i') : '') }}">
                </div>
            </div>
            <div class="mb-3">
                <label class="form-label">Local</label>
                <input type="text" name="local" class="form-control" value="{{ old('local', $evento->local) }}">
            </div>
            <div class="mb-3">
                <label class="form-label">Secretaria</label>
                <select name="structure_id" class="form-select">
                    @foreach($estruturas as $estrutura)
                        <option value="{{ $estrutura->id }}" @selected(old('structure_id', $evento->structure_id)===$estrutura->id)>{{ $estrutura->name }}</option>
                    @endforeach
                </select>
            </div>
            <button type="submit" class="btn btn-success">Salvar</button>
            <a href="{{ route('admin.eventos.index') }}" class="btn btn-secondary">Cancelar</a>
        </form>
    </div>
</section>
@endsection

