Review the instructions in this support article about what to do before you sell, give away, or trade in your iPhone or iPad
https://support.apple.com/109511
At the very least read this article to learn how to sign out of iCloud on your iPhone, iPad, iPod touch, Apple TV, or Mac --> https://support.apple.com/104958
For an Apple mobile device:
1. Open the Settings app, then tap your name.
2. Scroll down to the bottom.
3. Tap Sign Out.
4. Choose Erase this [Device].
5. Follow the onscreen prompts to learn what information will remain on your device or be erased.
6. Enter the passcode for that device or enter your Apple Account password. If you forgot your Apple Account password see —> https://support.apple.com/102656