diff --git a/src/helpers.php b/src/helpers.php index ff5df68..c4edc91 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -749,3 +749,17 @@ function is_api_request(Request $request): bool return $request->is(config('app.api_prefix').'/*'); } } + +if (! function_exists('request_ip')) { + /** + * Get the ip from the current request + */ + function request_ip(): ?string + { + if (env('CLOUDFLARE_ENABLED') && isset($_SERVER['HTTP_CF_CONNECTING_IP'])) { + return $_SERVER['HTTP_CF_CONNECTING_IP']; + } else { + return request()->ip(); + } + } +}