Use had with a past participle to show that one event happened before another past event. It is not needed in every narrative when the order is already clear.
Practical examples
The train had left before we arrived.
كان القطار قد غادر قبل وصولنا.
I realised that I had forgotten my notes.
أدركت أنني نسيت ملاحظاتي.
She had worked there for years before moving.
كانت قد عملت هناك سنوات قبل انتقالها.