I think you can use this code
$user_agent = $request->header('User-Agent'); $bname = 'Unknown'; $platform = 'Unknown'; //First get the platform? if (preg_match('/linux/i', $user_agent)) { $platform = 'linux'; } elseif (preg_match('/macintosh|mac os x/i', $user_agent)) { $platform = 'mac'; } elseif (preg_match('/windows|win32/i', $user_agent)) { $platform = 'windows'; } echo $platform; echo "<br>"; // Next get the name of the useragent yes seperately and for good reason if(preg_match('/MSIE/i',$user_agent) && !preg_match('/Opera/i',$user_agent)) { $bname = 'Internet Explorer'; $ub = "MSIE"; } elseif(preg_match('/Firefox/i',$user_agent)) { $bname = 'Mozilla Firefox'; $ub = "Firefox"; } elseif(preg_match('/Chrome/i',$user_agent)) { $bname = 'Google Chrome'; $ub = "Chrome"; } elseif(preg_match('/Safari/i',$user_agent)) { $bname = 'Apple Safari'; $ub = "Safari"; } elseif(preg_match('/Opera/i',$user_agent)) { $bname = 'Opera'; $ub = "Opera"; } elseif(preg_match('/Netscape/i',$user_agent)) { $bname = 'Netscape'; $ub = "Netscape"; } echo $bname;
this code may be helpful. or another laravel package https://github.com/antonioribeiro/tracker or https://github.com/jenssegers/agent
source share