]> BookStack Code Mirror - bookstack/blobdiff - app/Api/ApiToken.php
Code cleanup, bug squashing
[bookstack] / app / Api / ApiToken.php
index 523c3b8b80ec2a883e590b73cbf701d2d7e67829..defaa7e954af69354fc3f3c637720f392fbc005c 100644 (file)
@@ -1,11 +1,21 @@
 <?php namespace BookStack\Api;
 
 use BookStack\Auth\User;
+use BookStack\Interfaces\Loggable;
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Database\Eloquent\Relations\BelongsTo;
 use Illuminate\Support\Carbon;
 
-class ApiToken extends Model
+/**
+ * Class ApiToken
+ * @property int $id
+ * @property string $token_id
+ * @property string $secret
+ * @property string $name
+ * @property Carbon $expires_at
+ * @property User $user
+ */
+class ApiToken extends Model implements Loggable
 {
     protected $fillable = ['name', 'expires_at'];
     protected $casts = [
@@ -28,4 +38,12 @@ class ApiToken extends Model
     {
         return Carbon::now()->addYears(100)->format('Y-m-d');
     }
+
+    /**
+     * @inheritdoc
+     */
+    public function logDescriptor(): string
+    {
+        return "({$this->id}) {$this->name}; User: {$this->user->logDescriptor()}";
+    }
 }