File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,8 @@ public function getData()
4545 : data_get ($ foreignColumn , 'foreign_table ' );
4646 $ columnType = 'FK -> ' .$ foreignTable ;
4747 }
48- $ length = is_object ($ column ) && method_exists ($ column , 'getLength ' ) ? $ column ->getLength () : count ($ columns );
48+
49+ $ length = is_object ($ column ) && method_exists ($ column , 'getLength ' ) ? $ column ->getLength () : $ this ->extractNumber (data_get ($ column , 'type ' ));
4950
5051 $ details ['column ' ] = $ columnName ;
5152 $ details ['type ' ] = $ columnType .$ this ->determineUnsigned ($ column );
@@ -67,6 +68,13 @@ public function getData()
6768 return $ this ->collections ;
6869 }
6970
71+ private function extractNumber (string $ type ): ?int
72+ {
73+ preg_match ('/\d+/ ' , $ type , $ matches );
74+
75+ return ! empty ($ matches ) ? (int ) $ matches [0 ] : null ;
76+ }
77+
7078 private function determineUnsigned ($ column )
7179 {
7280 if (is_object ($ column ) && method_exists ($ column , 'getUnsigned ' )) {
You can’t perform that action at this time.
0 commit comments