I\'m building a laravel application where I want to keep track of client browser details such as browser name. How do I do it using Laravel ?
public function
In addition to the explanations from here, in order to detect the Rest API consumers like Postman and Insomnia, i merged with this answer and ended up having the following source code that performed better in my scenario
Route::get('browser', function () {
//create new agent instance
$agent = new Jenssegers\Agent\Agent();
//check if agent is robot
if ($agent->isRobot()) {
return $agent->robot();
}
//if agent is not robot then get agent browser and platform like Chrome in Linux
$agent = $agent->browser() . " in " . $agent->platform();
//if agent browser and platform not obtained, then we check the agent technology
if ($agent == ' in ') {
$agent = request()->header('User-Agent');
}
return $agent;});
So from the code above, i can detect browser, platform, robot and rest consumers like Postman and Insomnia.