форму.
Exception: The POST method is not supported for route pizzas/create. Supported methods: GET, HEAD.
app\Http\Controllers\PizzaController.php
public function store(Request $request)
{
return redirect('/');
}
routes\web.php
<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\PizzaController;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "web" middleware group. Make something great!
|
*/
Route::get('/', function () {
return view('welcome');
});
Route::get('/pizzas', [PizzaController::class, 'index']);
Route::get('/pizzas/create', [PizzaController::class, 'create']);
Route::post('/pizzas', [PizzaController::class, 'store']);
Route::get('/pizzas/{id}', [PizzaController::class, 'show']);
resources\views\pizzas\create.blade.php
@extends('layouts.layout')
@section('content')
<div class="wrapper create-pizza">
<h1>Create a new pizza</h1>
<form action="/pizzas" method="POST">
@csrf
<label for="name">Your name:</label>
<input type="text" id="name" name="name">
<label for="type">Choose pizza type:</label>
<select name="type" id="type">
<option value="margherita">Margherita</option>
<option value="hawaiian">Hawaiian</option>
<option value="veg supreme">Veg supreme</option>
<option value="volcano">Vilcano</option>
</select>
<label for="base">Choose pizza base:</label>
<select name="base" id="base">
<option value="cheesy crust">Cheey crust</option>
<option value="garlic crust">Garlic crust</option>
<option value="thin & crispy">Thin & crispy</option>
<option value="thick">Thick</option>
</select>
<input type="submit" value="Order Pizza">
</form>
</div>
@endsection
Egor, мы обнаружили что Ваше сообщение больше чем наполовину состоит из кода. Рекомендуем сохранять примеры кода на внешних источниках, например, https://paste.laravel.io
пишет pizzas/create а в форме /pizzas. что-то не то
Обсуждают сегодня