From ed442fa32c1d98293b94ba705b91a04acb7673d0 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Tue, 27 Feb 2018 17:25:54 +0100 Subject: [PATCH 1/2] Laravel 5.6 compatibility for inserting new activity into the database --- src/Models/UserLoginActivity.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Models/UserLoginActivity.php b/src/Models/UserLoginActivity.php index 67b4384..3bf1838 100644 --- a/src/Models/UserLoginActivity.php +++ b/src/Models/UserLoginActivity.php @@ -7,6 +7,10 @@ class UserLoginActivity extends Model { + /** + * Removes the "updated_at" column + */ + const UPDATED_AT = null; /** * The database table used by the model. @@ -27,7 +31,7 @@ class UserLoginActivity extends Model * * @var bool */ - public $timestamps = false; + public $timestamps = true; /** * The attributes that should be mutated to dates. From 655b4cc77ef11c2691ec4500e0ace229b6829f62 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Tue, 27 Feb 2018 18:05:17 +0100 Subject: [PATCH 2/2] Make getLatest really get the chronologically latest entries --- src/Handlers/EloquentHandler.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Handlers/EloquentHandler.php b/src/Handlers/EloquentHandler.php index 8afb47f..d0d745b 100644 --- a/src/Handlers/EloquentHandler.php +++ b/src/Handlers/EloquentHandler.php @@ -67,7 +67,7 @@ public function getLogs() { * @return mixed */ public function getLatestLogs($limit = null) { - return UserLoginActivity::take($this->setLimit($limit))->get(); + return UserLoginActivity::latest()->take($this->setLimit($limit))->get(); } @@ -87,7 +87,7 @@ public function getLoginLogs() { * @return mixed */ public function getLatestLoginLogs($limit = null) { - return UserLoginActivity::where('event', '=', 'login')->take($this->setLimit($limit))->get(); + return UserLoginActivity::latest()->where('event', '=', 'login')->take($this->setLimit($limit))->get(); } /** @@ -106,7 +106,7 @@ public function getLogoutLogs() { * @return mixed */ public function getLatestLogoutLogs($limit = null) { - return UserLoginActivity::where('event', '=', 'logout')->take($this->setLimit($limit))->get(); + return UserLoginActivity::latest()->where('event', '=', 'logout')->take($this->setLimit($limit))->get(); } /**