X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/1c43602f4bed60a84f47735ca8bc4a399018e013..refs/pull/5676/head:/app/Api/ApiToken.php diff --git a/app/Api/ApiToken.php b/app/Api/ApiToken.php index f44fde19a..ca89c813e 100644 --- a/app/Api/ApiToken.php +++ b/app/Api/ApiToken.php @@ -2,8 +2,9 @@ namespace BookStack\Api; -use BookStack\Auth\User; -use BookStack\Interfaces\Loggable; +use BookStack\Activity\Models\Loggable; +use BookStack\Users\Models\User; +use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Support\Carbon; @@ -20,6 +21,8 @@ use Illuminate\Support\Carbon; */ class ApiToken extends Model implements Loggable { + use HasFactory; + protected $fillable = ['name', 'expires_at']; protected $casts = [ 'expires_at' => 'date:Y-m-d', @@ -43,10 +46,18 @@ class ApiToken extends Model implements Loggable } /** - * @inheritdoc + * {@inheritdoc} */ public function logDescriptor(): string { return "({$this->id}) {$this->name}; User: {$this->user->logDescriptor()}"; } + + /** + * Get the URL for managing this token. + */ + public function getUrl(string $path = ''): string + { + return url("/http/source.bookstackapp.com/api-tokens/{$this->user_id}/{$this->id}/" . trim($path, '/')); + } }