我正在从此URL重定向 http://127.0.0.1:8000/aalc/submit_paper_step_one/9
此网址http://127.0.0.1:8000/aalc/submit_paper_step_one/9
为此,我正在尝试使用laravel默认的路由重定向方法
这是我的路线代码
Route::get('/submit_paper_step_two/{paper_url_id}','HomeController@submit_paper_step_two')->name('submit_paper_step_two')->middleware('guard.verified:'.$journal->journal_slug.','.$journal->journal_slug.'.verification.notice');
这就是我重定向的方式
return redirect()->route( $this->current_guard.'.submit_paper_step_two', [ 'paper_url_id' => $id ] );
我被重定向到了这个错误的URL
http://127.0.0.1:8000/aalc/submit_paper_step_two?paper_url_id=9
我有什么错误吗?
答案 0 :(得分:0)
第1步:将其更改为您的路线代码
Route::get('/submit_paper_step_one/{id}','HomeController@submit_paper_step_two')->name('submit_paper_step_one');
第2步:在代码中使用此重定向
return redirect()->route('submit_paper_step_one', $id );
答案 1 :(得分:0)
两天后,如果我自己发现 我的路线情况就是这样
Route::get('/submit_paper_step_two/{paper_url_id}','HomeController@submit_paper_step_two')->name('submit_paper_step_two')->middleware('guard.verified:'.$journal->journal_slug.','.$journal->journal_slug.'.verification.notice');
Route::post('/submit_paper_step_two','HomeController@submit_paper_step_two')->name('submit_paper_step_two')->middleware('guard.verified:'.$journal->journal_slug.','.$journal->journal_slug.'.verification.notice');
我定义了两个名称相同但方法不同的路由,以便实现我的目标 我更改了第二条路线的名称,并且有效
Route::get('/submit_paper_step_two/{paper_url_id}','HomeController@submit_paper_step_two')->name('submit_paper_step_two')->middleware('guard.verified:'.$journal->journal_slug.','.$journal->journal_slug.'.verification.notice');
Route::post('/submit_paper_step_two','HomeController@submit_paper_step_two')->name('submit_paper_step_two_post')->middleware('guard.verified:'.$journal->journal_slug.','.$journal->journal_slug.'.verification.notice');