aboutsummaryrefslogtreecommitdiff
path: root/src/CamilStaps/BotleaguesApi/Database/PasswordReminder.php
diff options
context:
space:
mode:
authorCamil Staps2015-05-14 11:18:12 +0200
committerCamil Staps2015-05-14 11:18:12 +0200
commita012ea9e7d5dd0baadb549e1460a8339224f37a5 (patch)
treea74414754eb8d00d21d92d1ca5be274235ac8e52 /src/CamilStaps/BotleaguesApi/Database/PasswordReminder.php
parentPassword reminders start (diff)
Own Model class; new namespaces Database and Controllers; RFC2822 dates
Diffstat (limited to 'src/CamilStaps/BotleaguesApi/Database/PasswordReminder.php')
-rw-r--r--src/CamilStaps/BotleaguesApi/Database/PasswordReminder.php38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/CamilStaps/BotleaguesApi/Database/PasswordReminder.php b/src/CamilStaps/BotleaguesApi/Database/PasswordReminder.php
new file mode 100644
index 0000000..40bc578
--- /dev/null
+++ b/src/CamilStaps/BotleaguesApi/Database/PasswordReminder.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: camilstaps
+ * Date: 13-5-15
+ * Time: 13:12
+ */
+
+namespace CamilStaps\BotleaguesApi\Database;
+
+use Illuminate\Support\Facades\Mail;
+
+class PasswordReminder extends Model {
+
+ protected $table = 'password_reminders';
+ protected $hidden = ['token'];
+ protected $fillable = ['userId', 'token', 'valid_till'];
+
+ /**
+ * Override the parent's save() function to automatically update the valid_till timestamp, and send an email
+ */
+ public function save(array $options = array()) {
+ $this->valid_till = date("Y-m-d H:i:s", time() + 3600);
+
+ $user = User::find($this->userId);
+ Mail::send('packages.camil-staps.botleagues-api.emails.auth.reminder', ['token' => $this->token], function($message) use ($user) {
+ $message->to($user->email, "User " . $user->id);
+ });
+
+ return parent::save($options);
+ }
+
+ /**
+ * Disable updated_at timestamp
+ */
+ public function setUpdatedAtAttribute($value) {}
+
+} \ No newline at end of file