"Israel needs to focus exclusively on hunting down all of the terrorists responsible for the attack, including the leadership of Hamas, and holding them accountable. Israel also needs to stop the influx of outside funding from countries like Iran. Bombing Gaza and punishing everyone living there for the actions of Hamas isn't going to destroy Hamas or end future terror attacks against Israel. The current approach is only going to exacerbate long-standing grievances between the Palestinians and Israel, and until those grievances are addressed, terrorist attacks against Israel will continue.
To defeat Hamas, Israel has to make supporting and joining them less attractive to Palestinians and potential recruits. This can be done by Israel recognizing and respecting a Palestinian state and improving the lives of the Palestinian people. Israel will need to play a direct role in rebuilding Gaza and improving infrastructure once the dust settles from this most recent bombardment. This, along with supporting economic development and offering livelihood opportunities, would go a long way in changing the attitude and mindset of those who live in Gaza. If Israel can show that they care more about the Palestinian people than Hamas, then Hamas will lose the support of the Palestinian people and their primary recruiting tool. This is the only way to destroy Hamas. To make this happen, it will take a concerted effort by the Israeli government, the UN, NGO's, and the Palestinians themselves."
It's called counterinsurgency mathematics, and it has been proven to be true in multiple theaters of war over the past few decades and it's happening in Gaza today.