我已经在routes/web.php
中创建了路线。
Route::prefix('home')->group(function () {
Route::view('/', 'landing.index', ['name' => 'landing.home']);
Route::post('/', 'SignupController@signup');
Route::view('thank-you', 'landing.thank-you', ['name' => 'landing.thankyou']);
});
但是,呼叫php artisan route:list
时会显示:
| Domain | Method | URI | Name | Action | Middleware |
+--------+----------+----------------+-------+----------------------------------------------------+-------------+
| | GET|HEAD | home | | Illuminate\Routing\ViewController | web |
| | POST | home | | App\Http\Controllers\SignupController@signup | web |
| | GET|HEAD | home/thank-you | | Illuminate\Routing\ViewController | web |
此外,该名称尚未注册。
答案 0 :(得分:0)
尝试一下:
Route::prefix('home')->group(function () {
Route::view('/', 'landing.index')->name('landing.home');
Route::post('/', 'SignupController@signup');
Route::view('thank-you', 'landing.thank-you')->name('landing.thankyou');
});
希望有帮助。
答案 1 :(得分:0)
这样的名称声明:
Route::prefix('home')->group(function () {
Route::view('/', 'landing.index', ['name' => 'landing.home'])->name("home");
Route::post('/', 'SignupController@signup')->name("home");
Route::view('thank-you', 'landing.thank-you', ['name' => 'landing.thankyou'])->name("thank-you");
});
生成URL
$url = route('home');
生成重定向
return redirect()->route('home');