在 Laravel 中使用 id 重定向

4 php laravel

尝试重定向到路线:

return Redirect::route('job_view', array('id' =>$id))
                ->with('succes','Alread Apply for this post');
Run Code Online (Sandbox Code Playgroud)

错误:UrlGenerator.php 第 314 行中的 InvalidArgumentException 路线 [job_view] 未定义。

路由在Web.php中定义

Route::get('/job_view/{id}','jobseekerController@job_view');
Run Code Online (Sandbox Code Playgroud)

小智 5

在您的 Web 定义中,您定义了 Id,但是当您调用重定向到 job_view 时,您没有向其中添加 id。改为执行此操作

return redirect()->to('job_view/'.$id);
Run Code Online (Sandbox Code Playgroud)