1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-07-06 17:01:11 +08:00
2019-12-13 00:10:10 +08:00

30 lines
499 B
PHP

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