diff options
Diffstat (limited to 'src/CamilStaps/BotleaguesApi/Database/User.php')
-rw-r--r-- | src/CamilStaps/BotleaguesApi/Database/User.php | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/CamilStaps/BotleaguesApi/Database/User.php b/src/CamilStaps/BotleaguesApi/Database/User.php index 0af91c3..e74bd82 100644 --- a/src/CamilStaps/BotleaguesApi/Database/User.php +++ b/src/CamilStaps/BotleaguesApi/Database/User.php @@ -5,6 +5,7 @@ use Illuminate\Auth\Authenticatable; use Illuminate\Auth\Passwords\CanResetPassword; use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract; +use Illuminate\Support\Facades\Hash; class User extends Model implements AuthenticatableContract, CanResetPasswordContract { @@ -22,6 +23,18 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon return UserToken::where('userId', $this->id)->where('token', $token)->where('valid_till', '>', date("Y-m-d H:i:s"))->count() > 0; } + public function findPasswordReminders($token = null) { + $base = PasswordReminder + ::where('userId', $this->id) + ->where('used_at', null) + ->where('valid_till', '>', date('Y-m-d H:i:s')); + if ($token == null) { + return $base->get(); + } else { + return $base->where('token', $token)->get(); + } + } + /** * Get the unique identifier for the user. * @@ -76,4 +89,8 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon public function getEmailForPasswordReset() { return $this->email; } + + public function setPasswordAttribute($password) { + $this->attributes['password'] = Hash::make($password); + } }
\ No newline at end of file |