Skip to content

Commit

Permalink
- Added request ip method
Browse files Browse the repository at this point in the history
  • Loading branch information
dash8x committed Feb 5, 2024
1 parent 202ba53 commit 12dedc9
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}

0 comments on commit 12dedc9

Please sign in to comment.