我是Laravel的新手。我正在学习如何创建用户注册页面。一切正常,但我陷入一个简单的问题。
UrlGenerator.php第304行中的ErrorException:路由[signup]未定义。(查看:C:\ Program Files(x86)\ Ampps \ www \ social \ resources \ views \ welcome.blade.php)
但是我定义了注册路线。这是我的routes.php文件
Route::get('/', function () {
return view('welcome');
})->name('home');
Route::post('/signup', [
'uses' => 'UserController@postSignUp',
'as' => 'signup'
]);
这是我的UserController.php
class UserController extends Controller
{
public function postSignUp(Request $request)
{
$email = $request['email'];
$first_name = $request['frist_name'];
$password = bcrypt($request['password']);
$user = new User();
$user->email = $email;
$user->frist_name = $first_name;
$user->password = $password;
$user->save();
return redirect()->back();
刀片文件为welcome.blade.php
<form action="{{ route('signup') }}" method="post">
<div class="form-group">
<label for="email"> Your E-mail </label>
<input class ="form-control" type="text" id="email" name="email" >
</div>
如果有人可以帮助我,我将倍感荣幸。谢谢
哦对不起。我忘了提到我正在使用Laravel版本:5.4.11
仅出于完整性考虑,自Laravel 5.4起,@ StuartWagner回答说,所有路由都位于/routes
文件夹内,而不再位于HTTP
文件夹内。
Web路由位于/routes/web.php
文件内部。
经常要求这样做,因为否则,您将需要深入浏览三个级别才能获得路线。
现在好得多了,它们位于/routes
文件夹中。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句