option('days'); $queue = $this->option('queue'); if ($queue) { dispatch(new CleanupStaleLocationsJob($days)); $this->info('Cleanup job dispatched to queue.'); return self::SUCCESS; } $this->info("Cleaning up data older than {$days} days..."); // Delete old location logs $deletedLogs = LocationLog::where('recorded_at', '<', now()->subDays($days)) ->delete(); $this->info("Deleted {$deletedLogs} old location log entries."); // Mark stale riders as offline $offlineThreshold = config('restaurant-delivery.firebase.location.offline_threshold', 120); $ridersMarkedOffline = Rider::where('is_online', true) ->where('last_location_update', '<', now()->subSeconds($offlineThreshold)) ->update(['is_online' => false]); $this->info("Marked {$ridersMarkedOffline} riders as offline (no update for {$offlineThreshold}s)."); return self::SUCCESS; } }