December 10, 2015 11:17

IPv6 addresses should be converted using MySQL's INET6_ATON function. To convert them back to their original value, use INET6_NTOA.

They should be stored as a VARBINARY(16).

This function is only available in MySQL 5.6+

In Laravel, if you're tracking visitors you could do something like this:

$ip = \DB::connection()->getPdo()->quote(request()->ip());

$visitor = Visitor::firstOrCreate([
    'longip' => \DB::raw("INET6_ATON({$ip})")
]);

Laravel, MySQL