| 12345678910111213141516171819202122232425262728 |
- <?php
- namespace App\Http\Controllers;
- use Illuminate\Http\Response;
- use Symfony\Component\HttpFoundation\BinaryFileResponse;
- class TeacherWeeklyStatsReportController extends Controller
- {
- /**
- * 浏览器内联打开周报 PDF(固定文件名 teacher-weekly-stats-latest.pdf)
- */
- public function open(): BinaryFileResponse|Response
- {
- $path = storage_path('app/reports/teacher-weekly-stats-latest.pdf');
- if (! is_file($path)) {
- return response(
- '尚未生成周报 PDF。请在后台「老师周报统计」页面点击「生成/刷新周报」,或执行:php artisan report:teacher-weekly-pdf',
- 404
- );
- }
- return response()->file($path, [
- 'Content-Type' => 'application/pdf',
- 'Content-Disposition' => 'inline; filename="teacher-weekly-stats.pdf"',
- ]);
- }
- }
|