I have this set of eloquent model:
class UserModel extends Model
{
protected $fillable = array(
'first_name',
'last_name',
'email',
'password',
'ip',
);
protected $table = 'users';
}
The idea is... I want to include the ip address of the client whenever he/she register as user on our site.
In Laravel 5.2, we can retrieve the client ip address using the Request() class
Request()->ip()
https://laravel.com/api/5.2/Illuminate/Http/Request.html#method_ip
When creating a user record using eloquent model, I use the create() method so I don't have to do the work around for us in assigning values of each field EXCEPT for the 'IP' field.
Is there any ways to automatically assigned the 'IP' field from UserModel with the value coming from Request()->ip() method?
public function createNewUser(Request $request) {
return $this->user->create($request->all());
}
Any suggestions/feedbacks would be appreciated.
Thanks!