jeudi 10 novembre 2016

Store IP Address in database during sign up in laravel 5.1

Hii i want to store ip addresss in database in laravel 5.1.I have searched in google to store ip address and they suggest me to store ip address like Request::ip(); or other method $request->ip();.when i used this and keep this line as $request->ip(); then it print the ip address.But I have used array $data in auth controller during sign up.

protected function create(array $data)
    {
        return User::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => bcrypt($data['password']),
           'ip' => $data->ip(),
        ]);
    }

the main problem is when i use this line as storing ip like this 'ip' => $data->ip(), it cause error
FatalErrorException in AuthController.php Call to a member function ip() on a non-object.The error is in this line 'ip' => $data->ip(). Can you please help me.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire