Grease a gratin dish with butter, roughly 24cm in diameter, or you can use a casserole dish that you can cook on the hob, put in the oven, and serve the dish in.
Heat the oil in a large frying pan/casserole, add the shallots and garlic, and cook gently, making sure they don’t take on any colour. This should take around 5 minutes.
Add the grated courgette and cook until there is no remaining liquid in the pan. You need to cook out the water to ensure the dish isn’t too watery. Set aside.
Melt the butter in a separate pan, stir in the flour to make a roux, and cook for a couple of minutes, stirring constantly. Slowly add in the milk, stirring to avoid any lumps. Season the sauce well with salt and pepper, along with a good grating of nutmeg, then allow to simmer very gently for 10 minutes, stirring regularly. If you do end up with some lumps, don't panic, just take a whisk and beat it firmly.
Remove the pan from the heat and add in the grated courgette mixture, 2 beaten eggs, and half of the grated cheese. Give this a good mix and then pour it into the gratin/casserole dish.
Arrange the sliced courgettes on top. If you are lucky enough to have different colours, then alternating them makes the dish very attractive. Sprinkle the top with the remaining cheese, and bake in the preheated oven for 30 minutes.
Serve with a crisp green salad for lunch or alongside your barbecued meat for dinner.
Notes
If you don't have any yellow courgettes, don't worry. The flavour isn't any different, it's just to make the dish more attractive.