@@ -377,21 +377,18 @@ public function enumValues($model, $table, $name)
377377 return "[] " ;
378378 }
379379
380- $ connection = $ model ->getConnection ();
381- $ driver = $ connection ->getDriverName ();
380+ $ driver = $ model ->getConnection ()->getDriverName ();
382381 $ values = null ;
383382
384383 if ($ driver === 'mysql ' ) {
385- $ type = DB ::connection ($ connection )
384+ $ type = DB ::connection ($ model -> getConnectionName () )
386385 ->select (DB ::raw ('SHOW COLUMNS FROM ' . $ table . ' WHERE Field = " ' . $ name . '" ' ))[0 ]->Type ;
387386
388387 preg_match_all ("/'([^']+)'/ " , $ type , $ matches );
389388
390- $ values = isset ($ matches [1 ]) ? $ matches [1 ] : array ();
391-
392- return "[' " . implode ("', ' " , $ values ) . "'] " ;
389+ $ values = isset ($ matches [1 ]) ? $ matches [1 ] : null ;
393390 } else if ($ driver === 'pgsql ' ) {
394- $ types = DB ::connection ($ connection )
391+ $ types = DB ::connection ($ model -> getConnectionName () )
395392 ->select (DB ::raw ("
396393 select matches[1]
397394 from pg_constraint, regexp_matches(consrc, '''(.+?)''', 'g') matches
@@ -400,10 +397,12 @@ public function enumValues($model, $table, $name)
400397 and conrelid = 'public. {$ table }'::regclass;
401398 " ));
402399
403- $ values = array ();
400+ if (count ($ types )) {
401+ $ values = array ();
404402
405- foreach ($ types as $ type ){
406- $ values [] = $ type ->matches ;
403+ foreach ($ types as $ type ){
404+ $ values [] = $ type ->matches ;
405+ }
407406 }
408407 }
409408
0 commit comments