@famgia/omnify-laravel 0.0.50 → 0.0.51

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.
package/dist/index.js CHANGED
@@ -22,7 +22,7 @@ import {
22
22
  schemaToBlueprint,
23
23
  toColumnName,
24
24
  toTableName
25
- } from "./chunk-JCVJ7V7S.js";
25
+ } from "./chunk-FSVH5TYU.js";
26
26
  export {
27
27
  formatColumnMethod,
28
28
  formatForeignKey,
package/dist/plugin.cjs CHANGED
@@ -1330,10 +1330,28 @@ function generateEntityBaseModel(schema, schemas, options, stubContent, authStub
1330
1330
  const className = toPascalCase(schema.name);
1331
1331
  const tableName = schema.options?.tableName ?? pluralize(toSnakeCase(schema.name));
1332
1332
  const isAuth = schema.options?.authenticatable ?? false;
1333
- const primaryKey = "id";
1334
- const idType = schema.options?.idType ?? "BigInt";
1335
- const isUuid = idType === "Uuid";
1336
- const isStringKey = idType === "Uuid" || idType === "String";
1333
+ const hasAutoId2 = schema.options?.id !== false;
1334
+ let primaryKey = "id";
1335
+ let isStringKey = false;
1336
+ let isUuid = false;
1337
+ let isNonIncrementing = false;
1338
+ if (hasAutoId2) {
1339
+ const idType = schema.options?.idType ?? "BigInt";
1340
+ isUuid = idType === "Uuid";
1341
+ isStringKey = idType === "Uuid" || idType === "String";
1342
+ isNonIncrementing = isUuid;
1343
+ } else {
1344
+ const properties2 = schema.properties ?? {};
1345
+ for (const [propName, propDef] of Object.entries(properties2)) {
1346
+ if (propDef.primary === true) {
1347
+ primaryKey = toSnakeCase(propName);
1348
+ const propType = propDef.type;
1349
+ isStringKey = propType === "String" || propType === "Text" || propType === "Email";
1350
+ isNonIncrementing = true;
1351
+ break;
1352
+ }
1353
+ }
1354
+ }
1337
1355
  const imports = [];
1338
1356
  const traits = [];
1339
1357
  const fillable = [];
@@ -1454,7 +1472,7 @@ ${docProperties.join("\n")}
1454
1472
  protected $keyType = 'string';
1455
1473
 
1456
1474
  ` : "";
1457
- const incrementing = isUuid ? ` /**
1475
+ const incrementing = isNonIncrementing ? ` /**
1458
1476
  * Indicates if the IDs are auto-incrementing.
1459
1477
  */
1460
1478
  public $incrementing = false;