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

Model Traits #113

Open
BenRutlandWeb opened this issue May 23, 2021 · 2 comments
Open

Model Traits #113

BenRutlandWeb opened this issue May 23, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@BenRutlandWeb
Copy link
Collaborator

Is your feature request related to a problem? Please describe.
To get the post featured image requires adding boilerplate methods that could be used as a trait

Describe the solution you'd like
A trait for things such as the post featured image and author. HasFeaturedImage

Describe alternatives you've considered
Adding the methods to the base class

Additional context
Perhaps a trait for HasAuthor, HasFeaturedImage, HasAttachment etc.

@BenRutlandWeb BenRutlandWeb added the enhancement New feature or request label May 23, 2021
@BenRutlandWeb
Copy link
Collaborator Author

An issue with this is the developer may create an extending model which would then return the incorrect model. I.e.

Director model extends User model.

Movie::author() method return an instance of User not Director.

The developer would be required to override the traits to change the subclass returned.

@BenRutlandWeb
Copy link
Collaborator Author

Is this solved by PHP8.1 #[\ReturnTypeWillChange]?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant