User IP address and location in Laravel 5.5 : <p>I am trying to get the ip address and location of user during registration...when user sign up for the first time I want to save the ip address and his location in the database in users table.</p>

<p>Please give me a solution to get the ip address and location of the new user...</p>

<p><strong>Below is the line which i am using but this gives me wrong IP address of localhost...</strong></p>

<pre><code>127.0.0.1

$user = new User([
        'firstname' =&gt; $data['firstname'],
        'lastname' =&gt; $data['lastname'],
        'company' =&gt; $data['company'],
        'email' =&gt; $data['email'],
        'password' =&gt; bcrypt($data['password']),
        'phone' =&gt; $data['phone'],
        'country' =&gt; $data['country'],
        'zipcode' =&gt; $data['zipcode'],
        'city' =&gt; $data['city'],
        'state' =&gt; $data['state'] == "other" ? $data['custom_state'] : $data['state'],
        'ip_address' =&gt; request()-&gt;ip(),
    ]);
</code></pre>
