我想更新数据库,并尝试将其重定向到Laravel 5.6中定义的url
public function update(Request $request, Apply1 $Apply1)
{
$Apply1 ->Given_Name=$request->Given_Name;
$Apply1 ->Surname=$request->Surname;
$Apply1 ->Date_Birth=$request->Date_Birth;
$Apply1 ->Place_Birth=$request->Place_Birth;
$Apply1 ->Mother_Name=$request->Mother_Name;
$Apply1 ->Father_Name=$request->Father_Name;
$Apply1 ->Passport_Number=$request->Passport_Number;
$Apply1 ->Passport_Issue_Date=$request->Passport_Issue_Date;
$Apply1 ->Passport_Expiry_Date=$request->Passport_Expiry_Date;
$Apply1 ->Type_Supporting_Doc=$request->Supporting_Doc;
$Apply1 ->Supporting_Doc_Form=$request->city;
$Apply1 ->Supp_Doc_Expiry_Date=$request->Supp_Expiry_Date;
$Apply1 ->E_mail_address=$request->mail_address;
$Apply1 ->Phone_Number=$request->Phone_Number;
$Apply1 ->Address=$request->Address;
$Apply1 ->City=$request->Permanent_City;
$Apply1 ->State=$request->Address;
$Apply1 ->Postal_Code=$request->Permanent_City;
$Apply1 ->save();
return redirect(Route('Apply1.show1', $Apply1->id));
}
我定义的路由在web.php文件中
Route::get('Apply1/show1/{id}', function ($id) {
return 'User '.$id;
});
,但最后仍然出现错误(“未定义路由[{$ name}]。”); 我已经定义了正确的路线,但是我不知道为什么我再次遇到此错误
答案 0 :(得分:0)
我想您没有正确遵循named route documentation。
您的路线:
Route::get('Apply1/show1/{id}', function ($id) {
return 'User '.$id;
});
根据文档,您需要在路由的末尾添加name
。就是说,您应该这样添加它。
Route::get('Apply1/show1/{id}', function ($id) {
return 'User '.$id;
})->name('Apply1.show1'); // you had not written this
这样,您将获得想要的结果。