lundi 2 octobre 2017

User IP address and location in Laravel 5.5

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.

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

Below is the line which i am using but this gives me wrong IP address of localhost...

127.0.0.1

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



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire