@famgia/omnify-laravel 0.0.81 → 0.0.82

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.cjs CHANGED
@@ -3387,6 +3387,17 @@ function getModuleName2(schema) {
3387
3387
  }
3388
3388
  return "";
3389
3389
  }
3390
+ function getFieldExpression(fieldName, propDef) {
3391
+ switch (propDef.type) {
3392
+ case "Date":
3393
+ return `$this->${fieldName}?->toDateString()`;
3394
+ case "DateTime":
3395
+ case "Timestamp":
3396
+ return `$this->${fieldName}?->toISOString()`;
3397
+ default:
3398
+ return `$this->${fieldName}`;
3399
+ }
3400
+ }
3390
3401
  function getPropertyOutput(propName, propDef, schemas, options) {
3391
3402
  const snakeName = toSnakeCase(propName);
3392
3403
  const lines = [];
@@ -3433,7 +3444,8 @@ function getPropertyOutput(propName, propDef, schemas, options) {
3433
3444
  }
3434
3445
  return lines;
3435
3446
  }
3436
- lines.push(` '${snakeName}' => $this->${snakeName},`);
3447
+ const expression = getFieldExpression(snakeName, propDef);
3448
+ lines.push(` '${snakeName}' => ${expression},`);
3437
3449
  return lines;
3438
3450
  }
3439
3451
  function generateResourceBase(schema, schemas, options) {