// codeigniter 4 delete with redirect data public function deletePet($id) { $pet = new Pets(); // Model $pet->delete($id); // delete data using id return redirect()->to('/user/pets')->with('success', 'Pet deleted successfully'); }