Solution:
You can use either of following ways:
$ua = $request->server('HTTP_USER_AGENT'); $ua = $request->header('User-Agent');