@famgia/omnify-laravel 2.0.8 → 2.0.9
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/{chunk-BWLXGHVF.js → chunk-FTQ35X5M.js} +27 -6
- package/dist/chunk-FTQ35X5M.js.map +1 -0
- package/dist/index.cjs +26 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/plugin.cjs +26 -5
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.js +1 -1
- package/package.json +4 -4
- package/dist/chunk-BWLXGHVF.js.map +0 -1
|
@@ -1849,12 +1849,26 @@ function generateEntityBaseModel(schema, schemas, options, stubContent, authStub
|
|
|
1849
1849
|
const className = toPascalCase(schema.name);
|
|
1850
1850
|
const tableName = schema.options?.tableName ?? pluralize(toSnakeCase(schema.name));
|
|
1851
1851
|
const isAuth = schema.options?.authenticatable ?? false;
|
|
1852
|
-
const
|
|
1852
|
+
const compositePrimaryKey = schema.options?.primaryKey;
|
|
1853
|
+
const isCompositePK = Array.isArray(compositePrimaryKey) && compositePrimaryKey.length > 1;
|
|
1854
|
+
const hasAutoId2 = schema.options?.id !== false && !compositePrimaryKey;
|
|
1853
1855
|
let primaryKey = "id";
|
|
1854
1856
|
let isStringKey = false;
|
|
1855
1857
|
let isUuid = false;
|
|
1856
1858
|
let isNonIncrementing = false;
|
|
1857
|
-
if (
|
|
1859
|
+
if (isCompositePK) {
|
|
1860
|
+
primaryKey = compositePrimaryKey.map((col) => toSnakeCase(col));
|
|
1861
|
+
isNonIncrementing = true;
|
|
1862
|
+
} else if (compositePrimaryKey && typeof compositePrimaryKey === "string") {
|
|
1863
|
+
primaryKey = toSnakeCase(compositePrimaryKey);
|
|
1864
|
+
isNonIncrementing = true;
|
|
1865
|
+
const properties2 = schema.properties ?? {};
|
|
1866
|
+
const propDef = properties2[compositePrimaryKey];
|
|
1867
|
+
if (propDef) {
|
|
1868
|
+
const propType = propDef.type;
|
|
1869
|
+
isStringKey = propType === "String" || propType === "Text" || propType === "Email";
|
|
1870
|
+
}
|
|
1871
|
+
} else if (hasAutoId2) {
|
|
1858
1872
|
const idType = schema.options?.idType ?? "BigInt";
|
|
1859
1873
|
isUuid = idType === "Uuid";
|
|
1860
1874
|
isStringKey = idType === "Uuid" || idType === "String";
|
|
@@ -2039,7 +2053,8 @@ ${docProperties.join("\n")}
|
|
|
2039
2053
|
imports.push("use Illuminate\\Database\\Eloquent\\Concerns\\HasUuids;");
|
|
2040
2054
|
traits.push(" use HasUuids;");
|
|
2041
2055
|
}
|
|
2042
|
-
const
|
|
2056
|
+
const primaryKeyPhp = Array.isArray(primaryKey) ? `[${primaryKey.map((k) => `'${k}'`).join(", ")}]` : `'${primaryKey}'`;
|
|
2057
|
+
const content = stub.replace(/\{\{BASE_MODEL_NAMESPACE\}\}/g, options.baseModelNamespace).replace(/\{\{BASE_MODEL_CLASS\}\}/g, options.baseModelClassName).replace(/\{\{CLASS_NAME\}\}/g, className).replace(/\{\{TABLE_NAME\}\}/g, tableName).replace(/\{\{PRIMARY_KEY\}\}/g, primaryKeyPhp).replace(/\{\{KEY_TYPE\}\}/g, keyType).replace(/\{\{INCREMENTING\}\}/g, incrementing).replace(/\{\{TIMESTAMPS\}\}/g, schema.options?.timestamps !== false ? "true" : "false").replace(/\{\{IMPORTS\}\}/g, [...new Set(imports)].sort().join("\n")).replace(/\{\{TRAITS\}\}/g, traits.join("\n")).replace(/\{\{DOC_COMMENT\}\}/g, docComment).replace(/\{\{FILLABLE\}\}/g, fillable.join("\n")).replace(/\{\{HIDDEN\}\}/g, hidden.join("\n")).replace(/\{\{APPENDS\}\}/g, appends.join("\n")).replace(/\{\{CASTS\}\}/g, casts.join("\n")).replace(/\{\{RELATIONS\}\}/g, relations.join("\n\n"));
|
|
2043
2058
|
return {
|
|
2044
2059
|
path: `${options.baseModelPath}/${className}BaseModel.php`,
|
|
2045
2060
|
content,
|
|
@@ -2282,7 +2297,7 @@ class {{CLASS_NAME}}BaseModel extends {{BASE_MODEL_CLASS}}
|
|
|
2282
2297
|
/**
|
|
2283
2298
|
* The primary key for the model.
|
|
2284
2299
|
*/
|
|
2285
|
-
protected $primaryKey =
|
|
2300
|
+
protected $primaryKey = {{PRIMARY_KEY}};
|
|
2286
2301
|
|
|
2287
2302
|
{{KEY_TYPE}}
|
|
2288
2303
|
{{INCREMENTING}}
|
|
@@ -2379,7 +2394,7 @@ class {{CLASS_NAME}}BaseModel extends Authenticatable
|
|
|
2379
2394
|
/**
|
|
2380
2395
|
* The primary key for the model.
|
|
2381
2396
|
*/
|
|
2382
|
-
protected $primaryKey =
|
|
2397
|
+
protected $primaryKey = {{PRIMARY_KEY}};
|
|
2383
2398
|
|
|
2384
2399
|
{{KEY_TYPE}}
|
|
2385
2400
|
{{INCREMENTING}}
|
|
@@ -2466,6 +2481,12 @@ class {{CLASS_NAME}}BaseModel extends Pivot
|
|
|
2466
2481
|
*/
|
|
2467
2482
|
protected $table = '{{TABLE_NAME}}';
|
|
2468
2483
|
|
|
2484
|
+
/**
|
|
2485
|
+
* The primary key for the model.
|
|
2486
|
+
*/
|
|
2487
|
+
protected $primaryKey = {{PRIMARY_KEY}};
|
|
2488
|
+
|
|
2489
|
+
{{KEY_TYPE}}
|
|
2469
2490
|
{{INCREMENTING}}
|
|
2470
2491
|
/**
|
|
2471
2492
|
* Indicates if the model should be timestamped.
|
|
@@ -5390,4 +5411,4 @@ export {
|
|
|
5390
5411
|
shouldGenerateAIGuides,
|
|
5391
5412
|
laravelPlugin
|
|
5392
5413
|
};
|
|
5393
|
-
//# sourceMappingURL=chunk-
|
|
5414
|
+
//# sourceMappingURL=chunk-FTQ35X5M.js.map
|