1 <?php namespace BookStack\Api;
3 use BookStack\Auth\User;
4 use Illuminate\Database\Eloquent\Model;
5 use Illuminate\Database\Eloquent\Relations\BelongsTo;
6 use Illuminate\Support\Carbon;
8 class ApiToken extends Model
10 protected $fillable = ['name', 'expires_at'];
12 'expires_at' => 'date:Y-m-d'
16 * Get the user that this token belongs to.
18 public function user(): BelongsTo
20 return $this->belongsTo(User::class);
24 * Get the default expiry value for an API token.
25 * Set to 100 years from now.
27 public static function defaultExpiry(): string
29 return Carbon::now()->addYears(100)->format('Y-m-d');