To have people stop attacking you should do the following:
1. Send a diplomatic mail asking the attacking party to stop the attack.
most members are looking for farms and attack in active accounts, doing so will let the attacking party know that you are an active player
2. Join an Alliance
alliance Members share attack and defense info on the War tab, if you are being attacked and you have an alliance member near by most of the times you members will send his troops to your bases as reinforcements to protect it.
3. Make your base a no gain Farm.
Stop training any kind of defense or troops, build only Aero Transports since you have no troops no one will attack you for Experience points and if you move your resources form one base to another before the attacker reaches your bases you will save your resources.
4. Use Cease fire from your Bag
if you don’t have one you can buy one from the in-game store.
There are just a few tips, there are a lot more ways you can defend your bases.
Hope this helps!