@@ -381,26 +381,28 @@ public function enumValues($model, $table, $name)
381381 $ values = null ;
382382
383383 if ($ driver === 'mysql ' ) {
384- $ type = DB ::select (DB ::raw ('SHOW COLUMNS FROM ' . $ table . ' WHERE Field = " ' . $ name . '" ' ))[0 ]->Type ;
384+ $ type = DB ::connection ($ model ->getConnectionName ())
385+ ->select (DB ::raw ('SHOW COLUMNS FROM ' . $ table . ' WHERE Field = " ' . $ name . '" ' ))[0 ]->Type ;
385386
386387 preg_match_all ("/'([^']+)'/ " , $ type , $ matches );
387388
388- $ values = isset ($ matches [1 ]) ? $ matches [1 ] : array ();
389-
390- return "[' " . implode ("', ' " , $ values ) . "'] " ;
389+ $ values = isset ($ matches [1 ]) ? $ matches [1 ] : null ;
391390 } else if ($ driver === 'pgsql ' ) {
392- $ types = DB ::select (DB ::raw ("
393- select matches[1]
394- from pg_constraint, regexp_matches(consrc, '''(.+?)''', 'g') matches
395- where contype = 'c'
396- and conname = ' {$ table }_ {$ name }_check'
397- and conrelid = 'public. {$ table }'::regclass;
398- " ));
399-
400- $ values = array ();
401-
402- foreach ($ types as $ type ){
403- $ values [] = $ type ->matches ;
391+ $ types = DB ::connection ($ model ->getConnectionName ())
392+ ->select (DB ::raw ("
393+ select matches[1]
394+ from pg_constraint, regexp_matches(consrc, '''(.+?)''', 'g') matches
395+ where contype = 'c'
396+ and conname = ' {$ table }_ {$ name }_check'
397+ and conrelid = 'public. {$ table }'::regclass;
398+ " ));
399+
400+ if (count ($ types )) {
401+ $ values = array ();
402+
403+ foreach ($ types as $ type ){
404+ $ values [] = $ type ->matches ;
405+ }
404406 }
405407 }
406408
0 commit comments