Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

Undefined variable: action

Ainda estou sem conseguir resolver esse problema. Vinicius, consegue me ajudar? =/

Series.Controller

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request; use App\Models\Series;

class SeriesController extends Controller { public function index(Request $request) { $series = Series::all(); //Faz a consulta no banco de dados

    $mensagemSucesso = session('mensagem.sucesso'); 

    return view('series.index')->with('series',$series)
        ->with('mensagemSucesso',$mensagemSucesso);
}

public function create()
{
    return view('series.create');
}

public function store(Request $request)
{
    $serie = Series::create($request->all()); 

    $request->session()->flash('mensagem.sucesso',"Série '$serie->nome' adicionada com sucesso");

    return redirect(route('series.index'));
}

public function destroy(Series $series)
{

    $series->delete();
    return redirect(route('series.index'))
        ->with('mensagem.sucesso',"Série '{$series->nome}' removida com sucesso");
}

public function edit(Series $series)
{

    return view('series.edit')->with('serie',$series);
}

}

################################################################################ edit.blade (Apenas está comentado aqui para não dar erro na página)

<x-series.form action="{{ route('series.store') }}" :nome="$serie->nome" />

################################################################################

index.blade

Adicionar Series
@isset($mensagemSucesso)
    <div class="alert alert-success">
        {{ $mensagemSucesso }}
    </div>
@endisset

<ul class="list-group">
    @foreach ($series as $serie)
    <li class="list-group-item d-flex justify-content-between align-items-center">
        {{$serie->nome}}

        <span class="d-flex">
            <a href=" {{ route('series.edit', $serie->id) }}" class="btn btn-primary btn-sm">
                Editar
            </a>

            <form action=" {{ route('series.destroy',$serie->id) }}" method="post" class="ms-2">
                @csrf 
                @method('DELETE')
                <button class="btn btn-danger btn-sm">
                    Exluir
                </button>
            </form>
        </span>
     </li>
     @endforeach 
</ul>

################################################################################

form.blade

@csrf
@isset($nome)
@method('PUT')
@endisset

<div class="mb-3">
    <label for="nome" class="form-label">Nome:</label>
    <input type="text"
           id="nome"
           name="nome"
           class="form-control"
           @isset($nome)value="{{ $nome }}"@endisset>
</div>
<button type="submit" class="btn btn-primary">Adicionar</button>

################################################################################

create.blade

<x-series.form action="{{ route('series.store') }}" />

1 resposta
solução!

Resolvido!