'datetime', ]; protected $appends = [ 'browser_name', 'browser_os_name', ]; public function user() { return $this->belongsTo(User::class); } protected function browserName(): Attribute { return Attribute::make( get: function () { $pattern = '/\b(Edge|Safari|Chrome|Firefox|Opera)\b/i'; // Regular expression pattern to match common browser names $matches = []; preg_match($pattern, $this->user_agent, $matches); if (isset($matches[1])) { $browserName = $matches[1]; return $browserName; } return 'Unknown'; }, ); } protected function browserOSName(): Attribute { return Attribute::make( get: function () { $pattern = '/\b(Android|Linux|Windows|iOS|MacOS)\b/i'; // Regular expression pattern to match common browser names $matches = []; preg_match($pattern, $this->user_agent, $matches); if (isset($matches[1])) { $browserName = $matches[1]; return $browserName; } return 'Unknown'; }, ); } }