@@ -232,6 +232,7 @@ protected function resolveProperty(
232
232
->setForeignKeyColumnName ($ property ->fkColName )
233
233
->setFakerStub ($ this ->guessFakerStub ($ attribute , $ property ))
234
234
->setTableName ($ this ->componentSchema ->resolveTableName ($ this ->schemaName ));
235
+
235
236
if ($ property ->isReference ()) {
236
237
if ($ property ->isVirtual ()) {
237
238
throw new InvalidDefinitionException ('References not supported for virtual attributes ' );
@@ -279,10 +280,8 @@ protected function resolveProperty(
279
280
$ relation ->asSelfReference ();
280
281
}
281
282
$ this ->relations [$ property ->getName ()] = $ relation ;
282
- if (!$ property ->isRefPointerToSelf () && $ property ->hasRefItems ()) {
283
- $ this ->addInverseRelation ($ relatedClassName , $ attribute , $ property , $ fkProperty );
284
- }
285
283
}
284
+
286
285
if (!$ property ->isReference () && !$ property ->hasRefItems ()) {
287
286
[$ min , $ max ] = $ property ->guessMinMax ();
288
287
$ attribute ->setIsVirtual ($ property ->isVirtual ())
@@ -337,7 +336,14 @@ protected function resolveProperty(
337
336
)
338
337
->asHasMany ([$ foreignPk => $ this ->componentSchema ->getPkName ()]);
339
338
return ;
339
+ } else { # handle inverse relation
340
+ if ($ property ->isReference ()) {
341
+ $ relatedClassName = $ property ->getRefClassName ();
342
+ $ fkProperty = $ property ->getTargetProperty ();
343
+ $ this ->addInverseRelation ($ relatedClassName , $ attribute , $ property , $ fkProperty );
344
+ }
340
345
}
346
+
341
347
$ relatedClassName = $ property ->getRefClassName ();
342
348
$ relatedTableName = $ property ->getRefSchema ()->resolveTableName ($ relatedClassName );
343
349
if ($ this ->catchManyToMany (
0 commit comments