X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/e15fcf5b50e1831a90a04ded09f24e0c7b31d02e..refs/pull/2393/head:/app/Auth/User.php diff --git a/app/Auth/User.php b/app/Auth/User.php index 28fb9c7fc..32179a1fb 100644 --- a/app/Auth/User.php +++ b/app/Auth/User.php @@ -1,6 +1,8 @@ roles->pluck('name')->contains($role); + return $this->roles->pluck('id')->contains($roleId); } /** @@ -160,7 +163,6 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon /** * Attach a role to this user. - * @param Role $role */ public function attachRole(Role $role) { @@ -229,6 +231,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. */ @@ -274,4 +284,12 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon { $this->notify(new ResetPassword($token)); } + + /** + * @inheritdoc + */ + public function logDescriptor(): string + { + return "({$this->id}) {$this->name}"; + } }