diff options
author | Camil Staps | 2015-05-14 11:18:12 +0200 |
---|---|---|
committer | Camil Staps | 2015-05-14 11:18:12 +0200 |
commit | a012ea9e7d5dd0baadb549e1460a8339224f37a5 (patch) | |
tree | a74414754eb8d00d21d92d1ca5be274235ac8e52 /src/CamilStaps/BotleaguesApi/Database/UserToken.php | |
parent | Password reminders start (diff) |
Own Model class; new namespaces Database and Controllers; RFC2822 dates
Diffstat (limited to 'src/CamilStaps/BotleaguesApi/Database/UserToken.php')
-rw-r--r-- | src/CamilStaps/BotleaguesApi/Database/UserToken.php | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/CamilStaps/BotleaguesApi/Database/UserToken.php b/src/CamilStaps/BotleaguesApi/Database/UserToken.php new file mode 100644 index 0000000..92b03b8 --- /dev/null +++ b/src/CamilStaps/BotleaguesApi/Database/UserToken.php @@ -0,0 +1,24 @@ +<?php +namespace CamilStaps\BotleaguesApi\Database; + +class UserToken extends Model { + + protected $table = 'user_tokens'; + protected $hidden = ['token']; + protected $fillable = ['userId', 'token', 'valid_till']; + protected $dates = ['created_at', 'updated_at', 'valid_till']; + + /** + * Override the parent's save() function to automatically update the valid_till timestamp + */ + public function save(array $options = array()) { + $this->valid_till = date("Y-m-d H:i:s", time() + 3600); + + return parent::save($options); + } + + public function getValidTillAttribute($attr) { + return $this->formatDate($attr); + } + +}
\ No newline at end of file |