@@ -110,10 +110,20 @@ protected function pickDateColumn(string $table, string $preferred): ?string
110110 return null ;
111111 }
112112
113+ /**
114+ * Resolve the excellence table name on this server (case/variant safe).
115+ */
116+ protected function excellenceTable (): ?string
117+ {
118+ if (Schema::hasTable ('excellences ' )) return 'excellences ' ;
119+ if (Schema::hasTable ('CertificatesOfExcellence ' )) return 'CertificatesOfExcellence ' ;
120+ return null ;
121+ }
122+
113123 protected function exportParticipations (string $ start , string $ end , bool $ inclusive , string $ datePref )
114124 {
115- $ table = 'participations ' ;
116- $ dateCol = $ this ->pickDateColumn ($ table , $ datePref ) ?? 'created_at ' ;
125+ $ table = 'participations ' ;
126+ $ dateCol = $ this ->pickDateColumn ($ table , $ datePref ) ?? 'created_at ' ;
117127 $ dateExpr = "p. $ dateCol " ;
118128
119129 $ q = DB ::table ('participations as p ' )
@@ -151,7 +161,7 @@ protected function exportParticipations(string $start, string $end, bool $inclus
151161 $ select [] = 'e.title as title ' ;
152162 } else {
153163 $ select [] = DB ::raw ('NULL as event_id ' );
154- $ select [] = DB ::raw ('NULL as title ' ); // `participations` has no native title in your DB
164+ $ select [] = DB ::raw ('NULL as title ' ); // `participations` has no native title
155165 }
156166
157167 return collect ($ q ->get ($ select ))->map (function ($ r ) {
@@ -171,41 +181,41 @@ protected function exportParticipations(string $start, string $end, bool $inclus
171181
172182 protected function exportExcellence (string $ start , string $ end , bool $ inclusive , string $ datePref )
173183 {
174- $ table = ' CertificatesOfExcellence ' ;
175- if (!Schema:: hasTable ( $ table ) ) return collect ();
184+ $ exTable = $ this -> excellenceTable () ;
185+ if (!$ exTable ) return collect ();
176186
177- $ dateCol = $ this ->pickDateColumn ($ table , $ datePref ) ?? 'created_at ' ;
178187 $ alias = 'x ' ;
188+ $ dateCol = $ this ->pickDateColumn ($ exTable , $ datePref ) ?? 'created_at ' ;
179189 $ dateExpr = "$ alias. $ dateCol " ;
180190
181- $ q = DB ::table ("$ table as $ alias " )
191+ $ q = DB ::table ("$ exTable as $ alias " )
182192 ->whereBetween ($ dateExpr , [$ start , $ end ])
183193 ->orderBy ("$ alias.id " );
184194
185- if (!$ inclusive && Schema::hasColumn ($ table , 'status ' )) {
195+ if (!$ inclusive && Schema::hasColumn ($ exTable , 'status ' )) {
186196 $ q ->where ("$ alias.status " , 'DONE ' );
187197 }
188198 if (!$ inclusive ) {
189- $ urlCol = Schema::hasColumn ($ table , 'certificate_url ' ) ? 'certificate_url '
190- : (Schema::hasColumn ($ table , 'url ' ) ? 'url ' : null );
199+ $ urlCol = Schema::hasColumn ($ exTable , 'certificate_url ' ) ? 'certificate_url '
200+ : (Schema::hasColumn ($ exTable , 'url ' ) ? 'url ' : null );
191201 if ($ urlCol ) $ q ->whereNotNull ("$ alias. $ urlCol " );
192202 }
193203
194204 // Build select list defensively
195205 $ select = ["$ alias.id as record_id " , DB ::raw ("$ dateExpr as issued_at " )];
196- $ select [] = Schema::hasColumn ($ table ,'event_date ' ) ? "$ alias.event_date " : DB ::raw ('NULL as event_date ' );
197- $ select [] = Schema::hasColumn ($ table ,'status ' ) ? "$ alias.status " : DB ::raw ('NULL as status ' );
206+ $ select [] = Schema::hasColumn ($ exTable ,'event_date ' ) ? "$ alias.event_date " : DB ::raw ('NULL as event_date ' );
207+ $ select [] = Schema::hasColumn ($ exTable ,'status ' ) ? "$ alias.status " : DB ::raw ('NULL as status ' );
198208
199- if (Schema::hasColumn ($ table ,'email ' )) $ select [] = "$ alias.email as owner_email " ;
200- elseif (Schema::hasColumn ($ table ,'user_email ' )) $ select [] = "$ alias.user_email as owner_email " ;
201- else $ select [] = DB ::raw ('NULL as owner_email ' );
209+ if (Schema::hasColumn ($ exTable ,'email ' )) $ select [] = "$ alias.email as owner_email " ;
210+ elseif (Schema::hasColumn ($ exTable ,'user_email ' )) $ select [] = "$ alias.user_email as owner_email " ;
211+ else $ select [] = DB ::raw ('NULL as owner_email ' );
202212
203- $ select [] = Schema::hasColumn ($ table ,'event_id ' ) ? "$ alias.event_id " : DB ::raw ('NULL as event_id ' );
204- $ select [] = Schema::hasColumn ($ table ,'title ' ) ? "$ alias.title " : DB ::raw ('NULL as title ' );
213+ $ select [] = Schema::hasColumn ($ exTable ,'event_id ' ) ? "$ alias.event_id " : DB ::raw ('NULL as event_id ' );
214+ $ select [] = Schema::hasColumn ($ exTable ,'title ' ) ? "$ alias.title " : DB ::raw ('NULL as title ' );
205215
206- if (Schema::hasColumn ($ table ,'certificate_url ' )) $ select [] = "$ alias.certificate_url as certificate_url " ;
207- elseif (Schema::hasColumn ($ table ,'url ' )) $ select [] = "$ alias.url as certificate_url " ;
208- else $ select [] = DB ::raw ('NULL as certificate_url ' );
216+ if (Schema::hasColumn ($ exTable ,'certificate_url ' )) $ select [] = "$ alias.certificate_url as certificate_url " ;
217+ elseif (Schema::hasColumn ($ exTable ,'url ' )) $ select [] = "$ alias.url as certificate_url " ;
218+ else $ select [] = DB ::raw ('NULL as certificate_url ' );
209219
210220 return collect ($ q ->get ($ select ))->map (function ($ r ) {
211221 return [
@@ -228,8 +238,8 @@ protected function printMonthly(string $family, string $start, string $end, bool
228238 $ table = 'participations ' ;
229239 $ alias = 'p ' ;
230240 } elseif ($ family === 'excellence ' ) {
231- $ table = ' CertificatesOfExcellence ' ;
232- if (!Schema:: hasTable ( $ table )) { $ this ->line (" { $ family } : table missing " ); return ; }
241+ $ table = $ this -> excellenceTable () ;
242+ if (!$ table ) { $ this ->line (" excellence : table missing " ); return ; }
233243 $ alias = 'x ' ;
234244 } else {
235245 return ;
0 commit comments