An example of extracting the agent's OS name using agent helper.
1echo agent()->os->name; // Windows
Dump agent helper.
1Pharaonic\Laravel\Agents\Classes\AgentDetector { 2 +"agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36" 3 +"ip": "127.0.0.1" 4 +"languages": array [ 5 0 => array [ 6 0 => "en" 7 1 => "US" 8 ] 9 1 => "en"10 2 => "ar"11 ]12 +"language": "en"13 +"variant": "US"14 +"id": 115 +"isBot": false16 +"bot": null17 +"type": "browser"18 +"device": {19 +"type": "desktop"20 +"brand": null21 +"model": null22 }23 +"os": {24 +"family": "Windows"25 +"name": "Windows"26 +"platform": "x64"27 }28 +"browser": {29 +"family": "Chrome"30 +"name": "Chrome"31 +"engine": "Blink"32 }33}
Also you can use agent middleware to auto detect the agents and store it in Database without displaying it immediately.
1Route::middleware('agent')->get('/', function () {2 return 'Agent has been detected!';3});