X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/baa260a03d872c59e8dd086a0969522df5e492d4..refs/pull/205/head:/app/User.php diff --git a/app/User.php b/app/User.php index 6ab7ad3bf..09b189cbb 100644 --- a/app/User.php +++ b/app/User.php @@ -1,13 +1,16 @@ 'guest', - 'name' => 'Guest' - ]); + return static::where('system_name', '=', 'public')->first(); + } + + /** + * Check if the user is the default public user. + * @return bool + */ + public function isDefault() + { + return $this->system_name === 'public'; } /** * The roles that belong to the user. + * @return BelongsToMany */ public function roles() { + if ($this->id === 0) return ; return $this->belongsToMany(Role::class); } @@ -160,6 +172,15 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon return baseUrl('/settings/users/' . $this->id); } + /** + * Get the url that links to this user's profile. + * @return mixed + */ + public function getProfileUrl() + { + return baseUrl('/user/' . $this->id); + } + /** * Get a shortened version of the user's name. * @param int $chars @@ -174,4 +195,14 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon return ''; } + + /** + * Send the password reset notification. + * @param string $token + * @return void + */ + public function sendPasswordResetNotification($token) + { + $this->notify(new ResetPassword($token)); + } }