Update
This commit is contained in:
@@ -34,10 +34,11 @@ public function handle()
|
||||
|
||||
if ($expiredTokens->isEmpty()) {
|
||||
$this->info('No expired tokens found.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->info('Found ' . $expiredTokens->count() . ' expired tokens to process.');
|
||||
$this->info('Found '.$expiredTokens->count().' expired tokens to process.');
|
||||
|
||||
$restoredCredits = 0;
|
||||
|
||||
@@ -47,10 +48,10 @@ public function handle()
|
||||
// Restore credits to user
|
||||
$token->user->user_usage()->increment('non_watermark_videos_left', $token->credits_reserved);
|
||||
$restoredCredits += $token->credits_reserved;
|
||||
|
||||
|
||||
$this->info("Restored {$token->credits_reserved} credits to user {$token->user_id}");
|
||||
}
|
||||
|
||||
|
||||
// Delete the expired token
|
||||
$token->delete();
|
||||
}
|
||||
@@ -58,4 +59,4 @@ public function handle()
|
||||
|
||||
$this->info("Cleanup completed. Restored {$restoredCredits} credits and deleted {$expiredTokens->count()} expired tokens.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public function premiumExportComplete(Request $request)
|
||||
->where('user_id', $user->id)
|
||||
->first();
|
||||
|
||||
if (!$token) {
|
||||
if (! $token) {
|
||||
return response()->json([
|
||||
'error' => [
|
||||
'message' => 'Invalid export token.',
|
||||
@@ -70,7 +70,7 @@ public function premiumExportComplete(Request $request)
|
||||
]);
|
||||
}
|
||||
|
||||
if (!$token->isValid()) {
|
||||
if (! $token->isValid()) {
|
||||
return response()->json([
|
||||
'error' => [
|
||||
'message' => 'Export token has expired or already been used.',
|
||||
|
||||
@@ -37,12 +37,12 @@ public function isExpired(): bool
|
||||
|
||||
public function isUsed(): bool
|
||||
{
|
||||
return !is_null($this->used_at);
|
||||
return ! is_null($this->used_at);
|
||||
}
|
||||
|
||||
public function isValid(): bool
|
||||
{
|
||||
return !$this->isExpired() && !$this->isUsed();
|
||||
return ! $this->isExpired() && ! $this->isUsed();
|
||||
}
|
||||
|
||||
public function markAsUsed(): void
|
||||
@@ -53,11 +53,11 @@ public function markAsUsed(): void
|
||||
public function scopeExpiredAndUnused($query)
|
||||
{
|
||||
return $query->where('expires_at', '<', now())
|
||||
->whereNull('used_at');
|
||||
->whereNull('used_at');
|
||||
}
|
||||
|
||||
public function scopeForUser($query, $userId)
|
||||
{
|
||||
return $query->where('user_id', $userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user