diff --git a/composer.json b/composer.json index c35b72d..a1d853c 100644 --- a/composer.json +++ b/composer.json @@ -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": { diff --git a/readme.md b/readme.md index 7f10529..5eca6d7 100644 --- a/readme.md +++ b/readme.md @@ -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 diff --git a/src/Models/Session.php b/src/Models/Session.php index f809a1a..1630df7 100644 --- a/src/Models/Session.php +++ b/src/Models/Session.php @@ -4,7 +4,7 @@ use Illuminate\Database\Eloquent\Model; -use Jenssegers\Agent\Agent; +use WhichBrowser; class Session extends Model { @@ -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(), ]; }