X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/dccb279c84a3f523f1c07ffc4ee4e2b526fd5384..refs/pull/1881/head:/app/Api/ApiToken.php diff --git a/app/Api/ApiToken.php b/app/Api/ApiToken.php index e7101387f..523c3b8b8 100644 --- a/app/Api/ApiToken.php +++ b/app/Api/ApiToken.php @@ -1,11 +1,31 @@ 'datetime:Y-m-d' + 'expires_at' => 'date:Y-m-d' ]; + + /** + * Get the user that this token belongs to. + */ + public function user(): BelongsTo + { + return $this->belongsTo(User::class); + } + + /** + * Get the default expiry value for an API token. + * Set to 100 years from now. + */ + public static function defaultExpiry(): string + { + return Carbon::now()->addYears(100)->format('Y-m-d'); + } }