Issues (82)

app/Traits/CaptureIpTrait.php (1 issue)

Severity
1
<?php
2
3
namespace App\Traits;
4
5
class CaptureIpTrait
6
{
7
    private $ipAddress = null;
0 ignored issues
show
The private property $ipAddress is not used, and could be removed.
Loading history...
8
9
    /**
10
     * Get the Ip Address of the user.
11
     *
12
     * @return string
13
     */
14
    public function getClientIp()
15
    {
16
        if (getenv('HTTP_CLIENT_IP')) {
17
            $ipAddress = getenv('HTTP_CLIENT_IP');
18
        } elseif (getenv('HTTP_X_FORWARDED_FOR')) {
19
            $ipAddress = getenv('HTTP_X_FORWARDED_FOR');
20
        } elseif (getenv('HTTP_X_FORWARDED')) {
21
            $ipAddress = getenv('HTTP_X_FORWARDED');
22
        } elseif (getenv('HTTP_FORWARDED_FOR')) {
23
            $ipAddress = getenv('HTTP_FORWARDED_FOR');
24
        } elseif (getenv('HTTP_FORWARDED')) {
25
            $ipAddress = getenv('HTTP_FORWARDED');
26
        } elseif (getenv('REMOTE_ADDR')) {
27
            $ipAddress = getenv('REMOTE_ADDR');
28
        } else {
29
            $ipAddress = config('settings.nullIpAddress');
30
        }
31
32
        return $ipAddress;
33
    }
34
}
35