@famgia/omnify-laravel 2.0.24 → 2.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2105,7 +2105,8 @@ function generateEntityBaseModel(schema, schemas, options, stubContent, authStub
2105
2105
  if (propDef.type === "Association") {
2106
2106
  const assoc = propDef;
2107
2107
  if (assoc.target) {
2108
- imports.push(`use ${options.modelNamespace}\\${toPascalCase(assoc.target)};`);
2108
+ const targetNs = assoc.targetNamespace ?? options.modelNamespace;
2109
+ imports.push(`use ${targetNs}\\${toPascalCase(assoc.target)};`);
2109
2110
  }
2110
2111
  relations.push(generateRelation(propName, assoc, schema, schemas, options));
2111
2112
  if (assoc.relation === "ManyToOne" || assoc.relation === "OneToOne") {
@@ -3477,15 +3478,16 @@ function generateAssociationFake(propertyName, property, schema, schemas, modelN
3477
3478
  if (property.type !== "Association") {
3478
3479
  return null;
3479
3480
  }
3480
- const relation = property.relation;
3481
- const target = property.target;
3482
- if (relation !== "ManyToOne" || !target) {
3481
+ const assoc = property;
3482
+ if (assoc.relation !== "ManyToOne" || !assoc.target) {
3483
3483
  return null;
3484
3484
  }
3485
+ const target = assoc.target;
3485
3486
  const foreignKey = `${toSnakeCase(propertyName)}_id`;
3486
- const isNullable2 = property.nullable ?? false;
3487
+ const isNullable2 = assoc.nullable ?? false;
3487
3488
  const targetSchema = schemas[target];
3488
- if (!targetSchema) {
3489
+ const targetNs = assoc.targetNamespace ?? modelNamespace;
3490
+ if (!targetSchema && !assoc.targetNamespace) {
3489
3491
  return null;
3490
3492
  }
3491
3493
  let fake;
@@ -3496,7 +3498,7 @@ function generateAssociationFake(propertyName, property, schema, schemas, modelN
3496
3498
  }
3497
3499
  let importStatement;
3498
3500
  if (target !== schema.name) {
3499
- importStatement = `use ${modelNamespace}\\${target};`;
3501
+ importStatement = `use ${targetNs}\\${target};`;
3500
3502
  }
3501
3503
  return { fake, import: importStatement };
3502
3504
  }
@@ -5461,4 +5463,4 @@ export {
5461
5463
  getFactoryPath,
5462
5464
  laravelPlugin
5463
5465
  };
5464
- //# sourceMappingURL=chunk-LAM2IBUF.js.map
5466
+ //# sourceMappingURL=chunk-FQYGLKZY.js.map