Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] Rename Model::$collection to $collectionClass #52186

Merged
merged 1 commit into from
Jul 18, 2024

Conversation

GromNaN
Copy link
Contributor

@GromNaN GromNaN commented Jul 18, 2024

After #52171, all projects using the package mongodb/laravel-mongodb will be broken. The property $collection is used for years as an alias for $table, as documented in Laravel MongoDB / Eloquent Models.

Would it be possible to choose a different name for the new static property in order to prevent update issues for hundreds of projects.

@GromNaN GromNaN changed the title Rename Model::$collection to $collectionClass [11.x] Rename Model::$collection to $collectionClass Jul 18, 2024
@taylorotwell taylorotwell merged commit 7d26b7e into laravel:11.x Jul 18, 2024
30 of 31 checks passed
@GromNaN GromNaN deleted the collection-class branch July 18, 2024 20:52
@GromNaN
Copy link
Contributor Author

GromNaN commented Jul 18, 2024

Thank you @taylorotwell

@henzeb
Copy link
Contributor

henzeb commented Jul 18, 2024

@taylorotwell, @GromNaN, @calebdw, still not getting why this class parameter is in Model and not in the trait ?

@calebdw
Copy link
Contributor

calebdw commented Jul 18, 2024

If the property is defined on the trait, then you would not be able to override it:

https://www.php.net/manual/en/language.oop5.traits.php

If a trait defines a property then a class can not define a property with the same name unless it is compatible (same visibility and type, readonly modifier, and initial value), otherwise a fatal error is issued.

@henzeb
Copy link
Contributor

henzeb commented Jul 19, 2024

If the property is defined on the trait, then you would not be able to override it:

https://www.php.net/manual/en/language.oop5.traits.php

If a trait defines a property then a class can not define a property with the same name unless it is compatible (same visibility and type, readonly modifier, and initial value), otherwise a fatal error is issued.

ok, forgot about that, but where would you need that trait for anyway, if it is permanently attached to the Model? one line extra and one line modified doesn't really count as "slimming it down"?

@devfrey
Copy link
Contributor

devfrey commented Jul 19, 2024

So now we have $builder and $collectionClass. Can't we rename the former to $builderClass for consistency?

@calebdw
Copy link
Contributor

calebdw commented Jul 19, 2024

I'd rather not, the Factory uses $model and the Model uses $factory as well

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.

5 participants