No, law does not demand that. You have to accept it to settle existing debt but that's it. For new customers you can demand any payment method you want. If they don't like it they are free to not form a contract. A cashless restaurant would be legal. They are just rare because of customer preference. But just look at online shops: they generally don't allow you to pay cash.