]> BookStack Code Mirror - bookstack/blobdiff - app/Auth/User.php
Added latest activity into users list view
[bookstack] / app / Auth / User.php
index 6bf656be383614d8839d461aa72b427eed40ec29..5feb269e2bd1ce7fc230070faac1b6f067a55e93 100644 (file)
@@ -1,5 +1,6 @@
 <?php namespace BookStack\Auth;
 
+use BookStack\Actions\Activity;
 use BookStack\Api\ApiToken;
 use BookStack\Interfaces\Loggable;
 use BookStack\Model;
@@ -12,6 +13,7 @@ use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
 use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
 use Illuminate\Database\Eloquent\Relations\BelongsToMany;
 use Illuminate\Database\Eloquent\Relations\HasMany;
+use Illuminate\Database\Eloquent\Relations\HasOne;
 use Illuminate\Notifications\Notifiable;
 
 /**
@@ -230,6 +232,14 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
         return $this->hasMany(ApiToken::class);
     }
 
+    /**
+     * Get the latest activity instance for this user.
+     */
+    public function latestActivity(): HasOne
+    {
+        return $this->hasOne(Activity::class)->latest();
+    }
+
     /**
      * Get the url for editing this user.
      */