hasColumn('exam_drafts', 'teacher_id') ? 'teacher_id' : ($this->hasColumn('exam_drafts', 'author_id') ? 'author_id' : null); $teacherFileColumn = $this->hasColumn('exam_drafts', 'teacher_file') ? 'teacher_file' : ($this->hasColumn('exam_drafts', 'author_file') ? 'author_file' : null); $teacherFilenameColumn = $this->hasColumn('exam_drafts', 'teacher_filename') ? 'teacher_filename' : ($this->hasColumn('exam_drafts', 'author_filename') ? 'author_filename' : null); $teacherCommentColumn = $this->hasColumn('exam_drafts', 'description') ? 'description' : ($this->hasColumn('exam_drafts', 'author_comment') ? 'author_comment' : null); $adminUserColumn = $this->hasColumn('exam_drafts', 'admin_id') ? 'admin_id' : ($this->hasColumn('exam_drafts', 'reviewer_id') ? 'reviewer_id' : null); $adminCommentsColumn = $this->hasColumn('exam_drafts', 'admin_comments') ? 'admin_comments' : ($this->hasColumn('exam_drafts', 'reviewer_comments') ? 'reviewer_comments' : null); return [ 'school_year' => (string) (Configuration::getConfig('school_year') ?? ''), 'semester' => (string) (Configuration::getConfig('semester') ?? ''), 'teacher_user_column' => $teacherUserColumn, 'teacher_file_column' => $teacherFileColumn, 'teacher_filename_column' => $teacherFilenameColumn, 'teacher_comment_column' => $teacherCommentColumn, 'admin_user_column' => $adminUserColumn, 'admin_comments_column' => $adminCommentsColumn, 'has_teacher_id' => $this->hasColumn('exam_drafts', 'teacher_id'), 'has_admin_id' => $this->hasColumn('exam_drafts', 'admin_id'), 'has_author_id' => $this->hasColumn('exam_drafts', 'author_id'), 'has_reviewer_id' => $this->hasColumn('exam_drafts', 'reviewer_id'), 'has_admin_comments' => $this->hasColumn('exam_drafts', 'admin_comments'), 'has_reviewer_comments' => $this->hasColumn('exam_drafts', 'reviewer_comments'), 'has_reviewed_at' => $this->hasColumn('exam_drafts', 'reviewed_at'), 'has_final_pdf' => $this->hasColumn('exam_drafts', 'final_pdf_file'), 'has_final_filename' => $this->hasColumn('exam_drafts', 'final_filename'), 'has_previous_draft_id' => $this->hasColumn('exam_drafts', 'previous_draft_id'), 'has_legacy' => $this->hasColumn('exam_drafts', 'is_legacy'), ]; } private function hasColumn(string $table, string $column): bool { try { return Schema::hasColumn($table, $column); } catch (\Throwable) { return false; } } }