Allow entity's methods calls#13
Conversation
|
Wait, what? Isn't there an oversite here? This will change behaviour for getting relationships won't it? Because say if an object belongsTo a user, then Surely, a better solution would be to add a __call to call the methods on the model? |
|
Sorry. I will have to look better into this. |
|
I still don't get why this has to go in the __get function??? |
|
So people can access methods using: {{ $entity->present()->methodName }} and not {{ $entity->present()->methodName() }} And not really think about it being a method or a property in the model. Of course people can just create a acessors (getPropertyNameAttribute), but this way they will also be able to create simple methods and, (only) from the presenter, access them as a properties. This is exactly what Eloquent does for relationships, isn't it? This should be exclusively used for relationships? My use case was for a rather complex method, which should be done with a relationship, but couldn't due to some limitations, so I grab some data and do some stuff in that method and return the collection I need. Not really the case for an accessor, imo. Of course I can extend the Laracasts\Presenter and just use my own, but I'm trying to contribute, because some other people may encounter the same problem. |
No description provided.