1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-07-04 16:01:35 +08:00
2020-03-16 15:33:36 +08:00

32 lines
531 B
PHP

<?php
namespace App\Traits;
use WhichBrowser\Parser as BrowserParser;
trait Client
{
public function getClientIp()
{
$clientIp = $this->request->getClientAddress();
return $clientIp;
}
public function getClientType()
{
$userAgent = $this->request->getServer('HTTP_USER_AGENT');
$result = new BrowserParser($userAgent);
$clientType = 'desktop';
if ($result->isMobile()) {
$clientType = 'mobile';
}
return $clientType;
}
}