8889841chome/clixcotz/mars.clix.co.tz/vendor/beyondcode/laravel-websockets/src/Console/CleanStatistics.php000066600000002272150515676650027522 0ustar00comment('Cleaning WebSocket Statistics...'); $appId = $this->argument('appId'); $maxAgeInDays = config('websockets.statistics.delete_statistics_older_than_days'); $cutOffDate = Carbon::now()->subDay($maxAgeInDays)->format('Y-m-d H:i:s'); $webSocketsStatisticsEntryModelClass = config('websockets.statistics.model'); $amountDeleted = $webSocketsStatisticsEntryModelClass::where('created_at', '<', $cutOffDate) ->when(! is_null($appId), function (Builder $query) use ($appId) { $query->where('app_id', $appId); }) ->delete(); $this->info("Deleted {$amountDeleted} record(s) from the WebSocket statistics."); $this->comment('All done!'); } }