@@ -377,21 +377,18 @@ public function enumValues($model, $table, $name)
377
377
return "[] " ;
378
378
}
379
379
380
- $ connection = $ model ->getConnection ();
381
- $ driver = $ connection ->getDriverName ();
380
+ $ driver = $ model ->getConnection ()->getDriverName ();
382
381
$ values = null ;
383
382
384
383
if ($ driver === 'mysql ' ) {
385
- $ type = DB ::connection ($ connection )
384
+ $ type = DB ::connection ($ model -> getConnectionName () )
386
385
->select (DB ::raw ('SHOW COLUMNS FROM ' . $ table . ' WHERE Field = " ' . $ name . '" ' ))[0 ]->Type ;
387
386
388
387
preg_match_all ("/'([^']+)'/ " , $ type , $ matches );
389
388
390
- $ values = isset ($ matches [1 ]) ? $ matches [1 ] : array ();
391
-
392
- return "[' " . implode ("', ' " , $ values ) . "'] " ;
389
+ $ values = isset ($ matches [1 ]) ? $ matches [1 ] : null ;
393
390
} else if ($ driver === 'pgsql ' ) {
394
- $ types = DB ::connection ($ connection )
391
+ $ types = DB ::connection ($ model -> getConnectionName () )
395
392
->select (DB ::raw ("
396
393
select matches[1]
397
394
from pg_constraint, regexp_matches(consrc, '''(.+?)''', 'g') matches
@@ -400,10 +397,12 @@ public function enumValues($model, $table, $name)
400
397
and conrelid = 'public. {$ table }'::regclass;
401
398
" ));
402
399
403
- $ values = array ();
400
+ if (count ($ types )) {
401
+ $ values = array ();
404
402
405
- foreach ($ types as $ type ){
406
- $ values [] = $ type ->matches ;
403
+ foreach ($ types as $ type ){
404
+ $ values [] = $ type ->matches ;
405
+ }
407
406
}
408
407
}
409
408
0 commit comments