Reputation: 21
I want to update my database and trying to redirect it to a defined url in Laravel 5.6
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));
}
and my defined route is in web.php file is
Route::get('Apply1/show1/{id}', function ($id) {
return 'User '.$id;
});
but still getting error in the end that ("Route [{$name}] not defined."); i have defined the correct route but i don,t know why i am getting this error again
Upvotes: 2
Views: 9913
Reputation: 4020
I guess you are not following the named route documentation properly.
Your route:
Route::get('Apply1/show1/{id}', function ($id) {
return 'User '.$id;
});
According to the documentation, you need to add name
at the end of the route. That means, you should add it like this..
Route::get('Apply1/show1/{id}', function ($id) {
return 'User '.$id;
})->name('Apply1.show1'); // you had not written this
In this way, you will get your desired result.
Upvotes: 3