Files
hstream/app/Console/Commands/ResetUserDownloads.php
2025-09-18 15:31:27 +02:00

41 lines
872 B
PHP

<?php
namespace App\Console\Commands;
use App\Models\User;
use App\Models\UserDownload;
use Illuminate\Support\Carbon;
use Illuminate\Console\Command;
class ResetUserDownloads extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:reset-user-downloads';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Resets the daily limit of user downloads';
/**
* Execute the console command.
*/
public function handle()
{
User::query()->update([
'downloads_left' => config('hstream.free_downloads_count'),
]);
// Clear old downloads which have expired
UserDownload::where('created_at', '<=', Carbon::now()->subHour(6))
->forceDelete();
}
}