Eloquent is probably one of the most powerful features of Laravel. It’s good, to an extent. I think that people certainly over use it and add business logic into models, but they should instead go into separate classes. I also don’t think that eloquent models should be used directly, instead they should be handled by repositories. The one thing I do like eloquent for is the relationships and the query scopes.
With collections, I find these useful from time to time - depending upon my use case. If I need to do some complicated operations on an array of data, filtering and sorting it is easier and clearer for any other developers to know what is happening.
I think it all comes down to personal preference and using the right tool for the use case.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Eloquent is probably one of the most powerful features of Laravel. It’s good, to an extent. I think that people certainly over use it and add business logic into models, but they should instead go into separate classes. I also don’t think that eloquent models should be used directly, instead they should be handled by repositories. The one thing I do like eloquent for is the relationships and the query scopes.
With collections, I find these useful from time to time - depending upon my use case. If I need to do some complicated operations on an array of data, filtering and sorting it is easier and clearer for any other developers to know what is happening.
I think it all comes down to personal preference and using the right tool for the use case.