@@ -278,7 +278,9 @@ protected function resolveProperty(
278
278
if ($ property ->isRefPointerToSelf ()) {
279
279
$ relation ->asSelfReference ();
280
280
}
281
- $ this ->relations [$ property ->getName ()] = $ relation ;
281
+ if (empty ($ property ->getAttr (CustomSpecAttr::NO_RELATION ))) {
282
+ $ this ->relations [$ property ->getName ()] = $ relation ;
283
+ }
282
284
if (!$ property ->isRefPointerToSelf ()) {
283
285
$ this ->addInverseRelation ($ relatedClassName , $ attribute , $ property , $ fkProperty );
284
286
}
@@ -321,21 +323,25 @@ protected function resolveProperty(
321
323
$ fkProperty ->getName (),
322
324
'_id '
323
325
)) {
326
+ if (empty ($ property ->getAttr (CustomSpecAttr::NO_RELATION ))) {
327
+ $ this ->relations [$ property ->getName ()] =
328
+ Yii::createObject (
329
+ AttributeRelation::class,
330
+ [static ::relationName ($ property ->getName (), $ property ->fkColName ), $ relatedTableName , $ relatedClassName ]
331
+ )
332
+ ->asHasMany ([$ fkProperty ->getName () => $ fkProperty ->getName ()])->asSelfReference ();
333
+ }
334
+ return ;
335
+ }
336
+ $ foreignPk = Inflector::camel2id ($ fkProperty ->getName (), '_ ' ) . '_id ' ;
337
+ if (empty ($ property ->getAttr (CustomSpecAttr::NO_RELATION ))) {
324
338
$ this ->relations [$ property ->getName ()] =
325
339
Yii::createObject (
326
340
AttributeRelation::class,
327
341
[static ::relationName ($ property ->getName (), $ property ->fkColName ), $ relatedTableName , $ relatedClassName ]
328
342
)
329
- ->asHasMany ([$ fkProperty ->getName () => $ fkProperty ->getName ()])->asSelfReference ();
330
- return ;
343
+ ->asHasMany ([$ foreignPk => $ this ->componentSchema ->getPkName ()]);
331
344
}
332
- $ foreignPk = Inflector::camel2id ($ fkProperty ->getName (), '_ ' ) . '_id ' ;
333
- $ this ->relations [$ property ->getName ()] =
334
- Yii::createObject (
335
- AttributeRelation::class,
336
- [static ::relationName ($ property ->getName (), $ property ->fkColName ), $ relatedTableName , $ relatedClassName ]
337
- )
338
- ->asHasMany ([$ foreignPk => $ this ->componentSchema ->getPkName ()]);
339
345
return ;
340
346
}
341
347
$ relatedClassName = $ property ->getRefClassName ();
@@ -349,13 +355,15 @@ protected function resolveProperty(
349
355
return ;
350
356
}
351
357
$ attribute ->setPhpType ($ relatedClassName . '[] ' );
352
- $ this ->relations [$ property ->getName ()] =
353
- Yii::createObject (
354
- AttributeRelation::class,
355
- [static ::relationName ($ property ->getName (), $ property ->fkColName ), $ relatedTableName , $ relatedClassName ]
356
- )
357
- ->asHasMany ([Inflector::camel2id ($ this ->schemaName , '_ ' ) . '_id ' => $ this ->componentSchema ->getPkName ()])
358
- ->setInverse (Inflector::variablize ($ this ->schemaName ));
358
+ if (empty ($ property ->getAttr (CustomSpecAttr::NO_RELATION ))) {
359
+ $ this ->relations [$ property ->getName ()] =
360
+ Yii::createObject (
361
+ AttributeRelation::class,
362
+ [static ::relationName ($ property ->getName (), $ property ->fkColName ), $ relatedTableName , $ relatedClassName ]
363
+ )
364
+ ->asHasMany ([Inflector::camel2id ($ this ->schemaName , '_ ' ) . '_id ' => $ this ->componentSchema ->getPkName ()])
365
+ ->setInverse (Inflector::variablize ($ this ->schemaName ));
366
+ }
359
367
return ;
360
368
}
361
369
if ($ this ->componentSchema ->isNonDb () && $ attribute ->isReference ()) {
0 commit comments