I'm trying to open a page from a button, but I need to send the id of the item where the button is in. For context this is a discussion forum page, in the users dash they are shown the forums they can comment on and there is a button on the bottom of each, what I need to send is that forums id, so that when they click on the button it takes them to the correct forum view.
How can I do this?
I'm trying different ways
<el-button type="primary" @click="submit(f.id)">
Answer
</el-button>
submit($id) {
var link = 'comments/' + $id;
this.$inertia.visit('comments/' + $id, {
$id,
});
},
<inertia-link class="el-button el-button--warning"
:href="'comments/' + f.id">
Answer
</inertia-link>
In my routes web.php
Route::resource('comments', 'ReplyController');
Route::get('comments/{id}', 'ReplyController@index');
The index in the controller
public function index($id)
{
$forum = DiscussionForum::where('id', $id)
->with('comment', 'user')->first();
$comment = Reply::with('discussionForum', 'user')
->where('discussion_forum_id', $forum->id)
->orderByDesc('updated_at')->get();
return Inertia::render('Forum/Comment.vue', [
'forum' => $forum,
'comments' => $comment
]);
}
This is not working, the redirect shows me a blank window inside the main page? How can I send the forum id correctly?
fvariable output? Have a look in your developer tools in the networking tab to see if you get any 500 errors, or the like. IsAPP_DEBUGset totrue?