@@ -13,9 +13,9 @@ class TypeScriptifyModel {
1313 /**
1414 * The fully qualified model name.
1515 *
16- * @var string
16+ * @var string|null
1717 */
18- private static string $ fullyQualifiedModelName ;
18+ private static string | null $ fullyQualifiedModelName = null ;
1919
2020 /**
2121 * The supported database connections.
@@ -43,6 +43,7 @@ private static function hasSupportedDatabaseConnection(): bool {
4343 private static function hasValidModel (): bool {
4444 $ className = self ::$ fullyQualifiedModelName ;
4545
46+ if (is_null ($ className )) return false ;
4647 if (!class_exists ($ className )) return false ;
4748 if (!is_subclass_of ($ className , Model::class)) return false ;
4849
@@ -69,7 +70,6 @@ private static function getTypeScriptType(stdClass $columnSchema): string {
6970 $ columnType = Str::of ($ columnSchema ->Type );
7071
7172 // @todo sets
72- // @todo enums
7373 $ mappedType = match (true ) {
7474 $ columnType ->startsWith ('bit ' ) => 'number ' ,
7575 $ columnType ->startsWith ('int ' ) => 'number ' ,
@@ -101,6 +101,7 @@ private static function getTypeScriptType(stdClass $columnSchema): string {
101101 $ columnType ->startsWith ('timestamp ' ) => 'string ' ,
102102 $ columnType ->startsWith ('mediumtext ' ) => 'string ' ,
103103 $ columnType ->startsWith ('mediumblob ' ) => 'string ' ,
104+ $ columnType ->startsWith ('enum ' ) => $ columnType ->after ('enum( ' )->before (') ' )->replace (', ' , '| ' ),
104105
105106 default => 'unknown ' ,
106107 };
0 commit comments