blob: f328f59a51985bae7f76b73fad72eb62a7cd96c9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
<?php
namespace CamilStaps\BotleaguesApi\Database;
class UserToken extends Model {
protected $table = 'user_tokens';
protected $hidden = ['token'];
protected $fillable = ['userEmail', '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);
}
public function refresh() {
$this->save();
}
}
|