Botão excluir não faz nenhuma ação
<?php
namespace App\Http\Controllers;
use App\Models\Serie;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class SeriesController extends Controller
{
public function index()
{
$series = Serie::query()->orderBy('nome')->get();
return view('series.index')->with('series', $series) ;
}
public function create()
{
return view('series.create');
}
public function store(Request $request)
{
Serie::create($request->all());
return redirect('/series');
}
public function destroy(Request $request)
{
Serie::destroy($request->serie);
return to_route('series.index');
}
}
<x-layout title="Séries">
<a href="/series/criar" class="btn btn-dark mb-2">Adicionar</a>
<ul class="list-group">
@foreach ( $series as $serie)
<li class="list-group-item d-flex justify-content-between align-items-center"> {{ $serie->nome }}
<form action="{{ route('series.destroy', $serie->id) }}" method="post">
@csrf
@method('DELETE')
<bnt class=" btn btn-danger btn-sm">Excluir</bnt>
</form>
</li>
@endforeach
</ul>
</x-layout>
<?php
use App\Http\Controllers\SeriesController;
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', function () {
return redirect('/series');
});
Route::get('/series', [SeriesController::class, 'index']);
Route::get('/series/criar', [SeriesController::class, 'create']);
Route::post('/series/salvar', [SeriesController::class, 'store']);
Route::delete('/series/destroy/{serie}',[SeriesController::class, 'destroy'])->name('series.destroy');