| 123456789101112131415161718192021222324252627282930 |
- <?php
- namespace App\Console\Commands;
- use Illuminate\Console\Command;
- class ReportTeacherWeeklyPdfCommand extends Command
- {
- protected $signature = 'report:teacher-weekly-pdf
- {--days=7 : 近几个自然日(本周期 = 含今日 0 点至今;上周期 = 紧邻的前若干个完整自然日;时区见 app.timezone)}';
- protected $description = '生成老师组卷与学情分析周报 PDF(文件名带日期与时间戳 teacher-weekly-stats-Y-m-d_His.pdf)';
- public function handle(): int
- {
- $script = base_path('scripts/report_teacher_weekly_stats_pdf.php');
- if (! is_file($script)) {
- $this->error('找不到脚本:'.$script);
- return self::FAILURE;
- }
- $days = max(1, min(366, (int) $this->option('days')));
- putenv('TEACHER_WEEKLY_REPORT_DAYS='.(string) $days);
- passthru(escapeshellarg(PHP_BINARY).' '.escapeshellarg($script), $code);
- return $code === 0 ? self::SUCCESS : self::FAILURE;
- }
- }
|