Skip to content

Commit

Permalink
🚀 switched from agent to whichbrowser, much better results
Browse files Browse the repository at this point in the history
  • Loading branch information
acidjazz committed Sep 4, 2018
1 parent 842fdce commit 47fa42f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"require": {
"illuminate/support": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.*",
"php": "~7.0",
"jenssegers/agent": "^2.6"
"whichbrowser/parser": "^2.0"
},
"autoload": {
"psr-4": {
Expand Down
13 changes: 12 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,18 @@
* Passwordless Authentication
* Ability to store and compare a cookie, securing the magic link sent out
* Ability for magic links to expire
* Detailed sessions using Jenssegers [Agent](https://github.com/jenssegers/agent)
* Detailed sessions using [whichbrowser](https://github.com/WhichBrowser/Parser-PHP)

```json
"device": {
"string": "Chrome 68 on a Google Pixel 2 XL running Android 9",
"platform": "Android 9",
"browser": "Chrome 68",
"name": "Google Pixel 2 XL",
"desktop": false,
"mobile": true
}
```

## Installation

Expand Down
14 changes: 7 additions & 7 deletions src/Models/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Illuminate\Database\Eloquent\Model;

use Jenssegers\Agent\Agent;
use WhichBrowser;

class Session extends Model {

Expand All @@ -20,13 +20,13 @@ public static function hash()

public function getDeviceAttribute ()
{
$agent = new Agent();
$agent->setUserAgent($this->agent);
$agent = new WhichBrowser\Parser($this->agent);
return [
'platform' => $agent->platform(),
'browser' => $agent->browser(),
'device' => $agent->device(),
'desktop' => $agent->isDesktop(),
'string' => $agent->toString(),
'platform' => $agent->os->toString(),
'browser' => $agent->browser->toString(),
'name' => $agent->device->toString(),
'desktop' => $agent->isType('desktop'),
'mobile' => $agent->isMobile(),
];
}
Expand Down

0 comments on commit 47fa42f

Please sign in to comment.