Skip to content

PHPLARA-133: Add support for Laravel 13 attributes - #3565

Open
paulinevos wants to merge 1 commit into
mongodb:5.xfrom
paulinevos:attribtues
Open

PHPLARA-133: Add support for Laravel 13 attributes#3565
paulinevos wants to merge 1 commit into
mongodb:5.xfrom
paulinevos:attribtues

Conversation

@paulinevos

Copy link
Copy Markdown
Contributor

Ensures support for the new attributes added to Laravel in this PR: laravel/framework#58578 by adding passing tests for them

Checklist

  • Add tests and ensure they pass

Copilot AI lite review requested due to automatic review settings August 13, 2026 13:29
@paulinevos
paulinevos requested a review from a team as a code owner August 13, 2026 13:29
@paulinevos
paulinevos requested a review from GromNaN August 13, 2026 13:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds coverage (and a small runtime adjustment) to ensure MongoDB Eloquent models correctly honor Laravel’s new Eloquent PHP attributes (as introduced upstream for Laravel 13), including behavior when using the DocumentModel trait.

Changes:

  • Added a comprehensive ModelAttributesTest exercising #[Table], #[Connection], #[Fillable], #[Hidden], #[Visible], #[Guarded], #[Unguarded], #[Appends], #[Touches], and factory attributes.
  • Introduced a set of minimal attributed test models/factory used by the new test suite.
  • Updated DocumentModel to apply #[Table(..., keyType: ...)] to keyType when the property hasn’t been explicitly overridden by user code.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/Models/AttributedVisibleDocument.php Adds a model using #[Visible] for test coverage.
tests/Models/AttributedUnguardedDocument.php Adds a model using #[Unguarded] for test coverage.
tests/Models/AttributedTraitDocument.php Adds an Eloquent base model using DocumentModel + #[Table] for trait coverage.
tests/Models/AttributedIntegerKeyDocument.php Adds a model using #[Table(..., keyType: 'int')] for key-type coverage.
tests/Models/AttributedGuardedDocument.php Adds a model using #[Guarded] for test coverage.
tests/Models/AttributedDocumentFactory.php Adds a factory using #[UseModel] to verify factory/model attribute wiring.
tests/Models/AttributedDocument.php Adds a model exercising multiple Laravel attributes end-to-end.
tests/Models/AttributedDeclaredKeyTypeDocument.php Adds a model ensuring $keyType property overrides the attribute.
tests/Models/AttributedAuthor.php Adds a related model for #[Touches] behavior verification.
tests/Eloquent/ModelAttributesTest.php New test suite validating Laravel attribute behavior against MongoDB models.
src/Eloquent/DocumentModel.php Ensures keyType can be derived from #[Table] when not explicitly overridden.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Ensures support for the new attributes added to Laravel in this PR:
laravel/framework#58578 by adding passing tests
for them
@GromNaN

GromNaN commented Aug 13, 2026

Copy link
Copy Markdown
Member

If I understand correctly, only Table::$keyType wasn't supported because it's overridden in the trait. But you added tests to ensure that all attributes are supported. Perfect!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants