File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -62,15 +62,7 @@ private function getForeignKeyTables(\ReflectionClass $bean) : array
6262 $ toReturn = [];
6363
6464 foreach ($ bean ->getProperties (\ReflectionProperty::IS_PUBLIC ) as $ property ) {
65- $ type = $ property ->getType ();
66-
67- if (!$ type instanceof \ReflectionNamedType || $ type ->isBuiltin () || !\str_contains ($ property ->getName (), '_ ' )) {
68- continue ;
69- }
70-
71- $ typeReflection = new \ReflectionClass ($ type ->getName ());
72-
73- if (!$ typeReflection ->isSubclassOf (\CoolBeans \Contract \PrimaryKey::class)) {
65+ if (!\CoolBeans \Command \SqlGeneratorCommand::isForeignKeyColumn ($ property )) {
7466 continue ;
7567 }
7668
@@ -100,9 +92,8 @@ private function getForeignKeyDependency(\ReflectionProperty $property) : ?strin
10092 return $ foreignKey ->table ;
10193 }
10294
103- $ parts = \explode ('_ ' , $ property ->getName ());
104- \array_pop ($ parts );
95+ [$ table , $ column ] = \CoolBeans \Command \SqlGeneratorCommand::getForeignKeyFromName ($ property ->getName ());
10596
106- return \implode ( ' _ ' , $ parts ) ;
97+ return $ table ;
10798 }
10899}
You can’t perform that action at this time.
0 commit comments