i want to redirect to my thread show but something error and missing
here is my route
Route::get('forum/{forumthread}', [
'uses' => 'ForumController@show',
'as' => 'forum.show'
]);
Route::get('forum/{forumthread}/create', [
'uses' => 'ForumController@indexcreate',
'as' => 'forum.index.create'
]);
here is my controller
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);
}
help me for this thank you
Have you tried to wrap the second argument of the route() function in array?
return redirect()->route('forum.show', ['slug' => $forum->slug]);
Here's the what the Laravel's documentation says:
If your route has parameters, you may pass them as the second argument to the route method:
// For a route with the following URI: profile/{id}
return redirect()->route('profile', ['id' => 1]);
尝试这个
return redirect()->action('ForumController@show', array('slug'=>$forum->slug));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.