'integer', 'store_id' => 'integer', 'created_by' => 'integer', 'updated_by' => 'integer', 'is_active' => 'boolean', 'expires_at' => 'datetime', ]; /** * Check if this access key is expired. */ public function isExpired(): bool { return $this->expires_at !== null && $this->expires_at->isPast(); } /** * Auto-expire: set all expired active keys to inactive. * Call this before listing or validating keys. */ public static function autoExpire(): void { self::where('status', 'active') ->whereNotNull('expires_at') ->where('expires_at', '<', now()) ->update(['status' => 'inactive']); } /** * Relationships */ public function store() { return $this->belongsTo(Store::class, 'store_id'); } public function creator() { return $this->belongsTo(User::class, 'created_by'); } }