option('date') ?? Carbon::today()->format('Y-m-d'); $type = $this->option('type'); $this->info("📊 Daily Statistics for {$date}"); $this->info(str_repeat('=', 50)); // You'll need to update your InboundReportService to have separate methods // أو تستخدم Services المنفصلة if ($type === 'all' || $type === 'answered') { $answered = \DB::table('inbound_reports') ->where('report_date', $date) ->where('call_status', 'answered') ->count(); $avgTalktime = \DB::table('inbound_reports') ->where('report_date', $date) ->where('call_status', 'answered') ->avg('talktime') ?? 0; $this->info("📞 Answered Calls:"); $this->info(" Total: {$answered}"); $this->info(" Average Talk Time: " . $this->secondsToTime($avgTalktime)); $this->info(""); } if ($type === 'all' || $type === 'missed') { $missed = \DB::table('inbound_reports') ->where('report_date', $date) ->where('call_status', 'missed') ->count(); $avgRingtime = \DB::table('inbound_reports') ->where('report_date', $date) ->where('call_status', 'missed') ->avg('ringtime') ?? 0; $this->info("❌ Missed Calls:"); $this->info(" Total: {$missed}"); $this->info(" Average Ring Time: " . $this->secondsToTime($avgRingtime)); $this->info(""); } if ($type === 'all') { $total = \DB::table('inbound_reports') ->where('report_date', $date) ->count(); $answerRate = $total > 0 ? round(($answered / $total) * 100, 2) : 0; $this->info("📈 Summary:"); $this->info(" Total Calls: {$total}"); $this->info(" Answer Rate: {$answerRate}%"); } return Command::SUCCESS; } private function secondsToTime($seconds) { if (!$seconds) return '00:00:00'; $hours = floor($seconds / 3600); $minutes = floor(($seconds % 3600) / 60); $secs = $seconds % 60; return sprintf('%02d:%02d:%02d', $hours, $minutes, $secs); } }