我想重定向到我的主题节目,但有些错误并且丢失了 这是我的路线
Route::get('forum/{forumthread}', [
'uses' => 'ForumController@show',
'as' => 'forum.show'
]);
Route::get('forum/{forumthread}/create', [
'uses' => 'ForumController@indexcreate',
'as' => 'forum.index.create'
]);
这是我的控制器
public function indexcreate($slug){
$forum = forumthread::where('slug', $slug)->first();
return view('forum.index.indexcreate', compact('forum'));
}
public function indexstore(Request $request, $slug){
$forumindex = new forumindex;
$forumindex->title = $request->title;
$forumindex->body = $request->body;
$forumindex->slug = EasySlug::generateSlug($forumindex->title, $separator = '-');
$forumindex->user_id = Auth::user()->id;
$forumindex->save();
return redirect()->route('forum.show', $forum->slug);
}
帮助我,谢谢你
答案 0 :(得分:0)
您是否尝试在数组中包装 route()函数的第二个参数?
return redirect()->route('forum.show', ['slug' => $forum->slug]);
这是Laravel's documentation所说的内容:
如果您的路线有参数,您可以将它们作为第二个参数传递 路线方法:
//对于具有以下URI的路由:profile / {id}
return redirect() - > route(' profile',[' id' => 1]);
答案 1 :(得分:0)
试试这个
return redirect()->action('ForumController@show', array('slug'=>$forum->slug));