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

Move model to a trait #2580

Draft
wants to merge 1 commit into
base: 4.1
Choose a base branch
from
Draft

Move model to a trait #2580

wants to merge 1 commit into from

Conversation

GromNaN
Copy link
Member

@GromNaN GromNaN commented Aug 28, 2023

Fix #2120

By moving all the logic to a trait, it make it possible to reuse entities provided by community projects. Example: https://github.com/z-song/laravel-admin/blob/master/src/Auth/Database/Administrator.php

The properties $primaryKey and $keyType can't be in the trait because PHP forbid declaring a property in a trait that is different (type and value) than the property declared in the parent class.

I have mixed feelings about this change, as it breaks the link with the overloaded parent methods. It would probably be better to make the change in each community-package when necessary.

@GromNaN
Copy link
Member Author

GromNaN commented Aug 29, 2023

Currently, the Model class is a marker for MongoDB models. If a trait is used, an other marker will be necessary.
https://github.com/mongodb-php/laravel-mongodb/blob/f06f7b3dca88cfd5cc6a823ff01051b4a46ca10a/src/Eloquent/HybridRelations.php#L145

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.

Update model to implement a trait to set mongo functionality
1 participant