@extends('layouts.app') {{-- Define a variável $evento como um novo Evento se não estiver definida (para a view 'create') --}} @php $isEdit = isset($evento) && $evento->exists; $titulo = $isEdit ? 'Editar Evento' : 'Cadastrar Novo Evento'; $action = $isEdit ? route('eventos.update', $evento) : route('eventos.store'); $method = $isEdit ? 'PUT' : 'POST'; $buttonText = $isEdit ? 'Atualizar Evento' : 'Cadastrar Evento'; // Lógica para carregar proponentes para edição/old $proponentesArray = old('proponentes'); if (!$proponentesArray && $isEdit) { // Assume que 'proponente' é uma coluna de texto no DB separada por vírgulas $proponentesString = $evento->proponente ?? ''; $proponentesArray = array_map('trim', explode(',', $proponentesString)); // Se a string for vazia (ou explode resultar em ['']), garante pelo menos um campo vazio if (empty(array_filter($proponentesArray))) { $proponentesArray = ['']; } } elseif (!$proponentesArray) { $proponentesArray = ['']; // Para a criação, sempre começa com um campo } @endphp @section('content')
{{ $titulo }}
{{-- Container para alinhar os botões à direita --}}
@if($isEdit) {{-- BOTÃO VISUALIZAR (Olho) --}} {{-- Corrigido o link para 'show' e o ícone para 'olho' --}} Visualizar @endif {{-- BOTÃO VOLTAR --}} Voltar
@if ($errors->any())
@endif
@csrf @if ($isEdit) @method('PUT') @endif {{-- CAMPOS DE DETALHE --}}
{{-- Nome --}}
@error('nome')

{{ $message }}

@enderror
{{-- Local (Autocomplete) --}}
@error('local_id')

{{ $message }}

@enderror {{-- Informações do local (visível por JS) --}}
{{-- CAMPO PROPONENTE(S) (LISTA DINÂMICA) --}}
@foreach ($proponentesArray as $index => $proponente)
@endforeach
@error('proponentes')

{{ $message }}

@enderror
{{-- CAMPOS DE DATA, QUANTIDADE E STATUS --}}
{{-- 1. CAMPO DATA E HORA --}}
@error('data_evento')

{{ $message }}

@enderror
{{-- 2. CAMPO QUANTIDADE DE PESSOAS --}}
@error('quantidade_pessoas')

{{ $message }}

@enderror
{{-- 3. CAMPO STATUS --}}
@php // Define o valor atual (se estiver em edição, usa o valor do evento, senão 'ativo' como default) $currentStatus = old('status', $evento->status ?? 'ativo'); $statuses = [ 'ativo' => 'Ativo', 'cancelado' => 'Cancelado', 'adiado' => 'Adiado', ]; @endphp @error('status')

{{ $message }}

@enderror
Cancelar
@endsection @section('styles') @endsection @section('scripts') @endsection