-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Should Model class implement the magic setter/getter methods for protected properties? #720
Comments
Why do you need the table outside of the model? Isn't that the point of the model - to separate out the persistence from the rest of the app? |
Yes, that's the point of the model, but... I'm trying to achieve something like what you did in SprintPHP And when I say "something like" I mean "exactly that" ;-). Is it there a better way? |
:) In that case, use Reflection and you can get protected/private properties. However, you could also contribute to vulcan which is a code generation suite I've worked on a bit. it's not complete just yet, but has a pretty good start. |
CI4 already has a ReflectionHelper trait that provides a couple of methods for reading/writing protected fields. |
Awesome thing! I didn't know about "vulcan". I'm gonna give it a look and see if I can cooperate in some way, considering that my coding skills are not that great and are definitely outdated. |
for example to get the table name from the model
$model->getTable()
without having to declare $table as public in the model.
The text was updated successfully, but these errors were encountered: