@@ -20,27 +20,45 @@ public function getData()
2020
2121 $ this ->collections = [];
2222 foreach ($ tables as $ table ) {
23- $ columns = $ schema ->listTableColumns ($ table );
24- $ foreignKeys = collect ($ schema ->listTableForeignKeys ($ table ))->keyBy (function ($ foreignColumn ) {
25- return $ foreignColumn ->getLocalColumns ()[0 ];
23+ $ columns = method_exists ($ schema , 'listTableColumns ' )
24+ ? $ schema ->listTableColumns ($ table )
25+ : $ schema ->getColumns ($ table );
26+ $ foreignKeys = collect (
27+ method_exists ($ schema , 'listTableForeignKeys ' )
28+ ? $ schema ->listTableForeignKeys ($ table )
29+ : $ schema ->getForeignKeys ($ table )
30+ )->keyBy (function ($ foreignColumn ) {
31+ if (is_object ($ foreignColumn ) && method_exists ($ foreignColumn , 'getLocalColumns ' )) {
32+ return $ foreignColumn ->getLocalColumns ()[0 ];
33+ }
34+
35+ return data_get ($ foreignColumn , 'columns.0 ' );
2636 });
2737
2838 foreach ($ columns as $ column ) {
29- $ columnName = $ column ->getName ();
30- $ columnType = $ column ->getType ()->getName ();
39+ $ columnName = is_object ( $ column) && method_exists ( $ column , ' getName ' ) ? $ column ->getName () : data_get ( $ column , ' name ' );
40+ $ columnType = is_object ( $ column) && method_exists ( $ column , ' getType ' ) ? $ column ->getType ()->getName () : data_get ( $ column , ' type_name ' );
3141 if (isset ($ foreignKeys [$ columnName ])) {
3242 $ foreignColumn = $ foreignKeys [$ columnName ];
33- $ foreignTable = $ foreignColumn ->getForeignTableName ();
43+ $ foreignTable = is_object ($ foreignColumn ) && method_exists ($ foreignColumn , 'getForeignTableName ' )
44+ ? $ foreignColumn ->getForeignTableName ()
45+ : data_get ($ foreignColumn , 'foreign_table ' );
3446 $ columnType = 'FK -> ' .$ foreignTable ;
3547 }
36- $ length = $ column ->getLength ();
48+ $ length = is_object ( $ column) && method_exists ( $ column , ' getLength ' ) ? $ column ->getLength () : count ( $ columns );
3749
3850 $ details ['column ' ] = $ columnName ;
3951 $ details ['type ' ] = $ columnType .$ this ->determineUnsigned ($ column );
4052 $ details ['length ' ] = $ length != 0 ? $ length : null ;
4153 $ details ['default ' ] = $ this ->getDefaultValue ($ column );
42- $ details ['nullable ' ] = $ this ->getExpression (! $ column ->getNotNull () === true );
43- $ details ['comment ' ] = $ column ->getComment ();
54+ $ details ['nullable ' ] = $ this ->getExpression (
55+ is_object ($ column ) && method_exists ($ column , 'getNotNull ' )
56+ ? ! $ column ->getNotNull () === true
57+ : ! data_get ($ column , 'nullable ' )
58+ );
59+ $ details ['comment ' ] = is_object ($ column ) && method_exists ($ column , 'getComment ' )
60+ ? $ column ->getComment ()
61+ : data_get ($ column , 'comment ' );
4462
4563 $ this ->collections [$ table ][] = $ details ;
4664 }
@@ -51,16 +69,26 @@ public function getData()
5169
5270 private function determineUnsigned ($ column )
5371 {
54- return ($ column ->getUnsigned () === true ) ? '(unsigned) ' : '' ;
72+ if (is_object ($ column ) && method_exists ($ column , 'getUnsigned ' )) {
73+ return ($ column ->getUnsigned () === true ) ? '(unsigned) ' : '' ;
74+ }
75+
76+ return str_contains (
77+ data_get ($ column , 'type ' ), 'unsigned '
78+ ) === true ? '(unsigned) ' : '' ;
5579 }
5680
5781 private function getDefaultValue ($ column )
5882 {
59- if ($ column ->getType ()->getName () == 'boolean ' ) {
83+ if (is_object ( $ column ) && method_exists ( $ column , ' getType ' ) && $ column ->getType ()->getName () == 'boolean ' ) {
6084 return $ column ->getDefault () ? 'true ' : 'false ' ;
6185 }
6286
63- return $ column ->getDefault ();
87+ if (is_object ($ column ) && method_exists ($ column , 'getDefault ' )) {
88+ return $ column ->getDefault ();
89+ }
90+
91+ return data_get ($ column , 'default ' ) ? 'true ' : 'false ' ;
6492 }
6593
6694 private function getExpression ($ status )
0 commit comments