@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')