How would you extend the EnumarableMethods trait? #316
Replies: 2 comments 5 replies
-
You can create a custom data collection and use it within all your data classes by creating an abstract data class from which you extend. In that custom collection you could add such a method. |
Beta Was this translation helpful? Give feedback.
-
Is there any good reason why the DataCollection does not inherit from Laravel's base collection ( |
Beta Was this translation helpful? Give feedback.
-
I have a need for a
second()
, much like thefirst()
, method inside EnumerableMethods.php, but I realise it's very specific to my needs and therefore don't want to create a PR for it.Is there a way to extend or inject a method into every instance of a
DataCollection
so that I can call into thatsecond()
method on it?I have a working example of getting to the second item using
where()
:Ideally I would like to add:
Beta Was this translation helpful? Give feedback.
All reactions