storm icon indicating copy to clipboard operation
storm copied to clipboard

Update our override of Laravel's attributesToArray()

Open mjauvin opened this issue 2 weeks ago • 1 comments

  • Use base Model methods instead of re-implementing them ourselves.
  • Add our before/after events.
  • Handle model's $jsonable array since Laravel doesn't seem to handle this.
  • Using base model addCastAttributesToArray() also adds casting types not supported before:
    • date:<format>
    • datetime:<format>

Note: in order for created_at/updated_at columns to be used in $casts, the model's $timestamps property needs to be false.

Summary by CodeRabbit

  • Refactor

    • Consolidated internal attribute transformation logic into dedicated helper routines to improve maintainability and reliability.
  • Tests

    • Added coverage verifying date and cast handling to ensure attribute serialization behaves as expected.

Note: No user-facing changes or public API updates in this release.

✏️ Tip: You can customize this high-level summary in your review settings.

mjauvin avatar Dec 15 '25 22:12 mjauvin