I've recently built a module. In the twig template that I render, you can delete an item.
For example it goes to /delete/item/1
. That works fine. that route triggers a delete method from my controller
public function deleteFittest(){
$connection = \Drupal::service('database');
$query = $connection->delete('user_fittests')
->condition('id', \Drupal::request()->query->get('id'))
->condition('user_id', \Drupal::currentUser()->id())
->execute();
return $this->redirect_to('mib_my_fit_test.my_fittest');
}
After the delete, I want to redirect the user to the page that he was on, in this case the 'index' page. But none of the found redirect methods on the internet that I've found work. So what is the proper way to redirect to go to the routing name from my code example?