You can use this library to detect if request is done through Cloudflare.
$cloudflare = new CloudflareDetector();
echo($cloudflare->isCloudflareRequest());
echo($cloudflare->getConnectingRequestIp());
echo($cloudflare->getConnectingCountryCode());