'array', 'generated_at' => 'datetime', 'expires_at' => 'datetime', 'created_at' => 'datetime', 'updated_at' => 'datetime', ]; /** * 获取报告所属学生 */ public function student(): BelongsTo { return $this->belongsTo(Student::class, 'student_id', 'student_id'); } /** * 报告类型常量 */ const REPORT_TYPE_MASTERY_ANALYSIS = 'mastery_analysis'; const REPORT_TYPE_EXAM_REPORT = 'exam_report'; const REPORT_TYPE_LEARNING_PROGRESS = 'learning_progress'; /** * 生成状态常量 */ const STATUS_PENDING = 'pending'; const STATUS_COMPLETED = 'completed'; const STATUS_FAILED = 'failed'; /** * 作用域:仅获取已完成的报告 */ public function scopeCompleted($query) { return $query->where('generation_status', self::STATUS_COMPLETED); } /** * 作用域:按报告类型筛选 */ public function scopeOfType($query, string $type) { return $query->where('report_type', $type); } }