Yes, you can use manual visits in Inertia to achieve this functionality. Here's an example of how you can do it:
- In your Vue component, create a method to handle the delete action:
methods: {
deletePosts() {
this.$inertia.post('/posts/delete', { ids: this.ids }).then(() => {
this.$inertia.visit(this.$page.current_url)
})
}
}
- In your Laravel controller, handle the delete action and return a response:
public function delete(Request $request)
{
$ids = $request->input('ids');
Post::whereIn('id', $ids)->delete();
return response()->json(true);
}
- In your Laravel route file, define the route for the delete action:
Route::post('/posts/delete', [PostController::class, 'delete']);
This will delete the selected posts and then reload the current page using Inertia's manual visit method.