Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi @usmanhalalit!
I might have overdone it a little bit so please correct me since I do not know the reason some stuff was put in.
The real reason for this pull request was the call to
$model->toArray()
which can sometimes have unwanted side effects. Developers often know the best way to eager/lazy load their data and when triggering thetoArray
function appends and visible fields are triggered while they may not be used in exporting at all. Retrieving attributes from models/arrays directly actually allows you to pull them one by one, visible or not.Which led me to remove the
if
to check whether an Eloquent collection is at play which let me remove the$isEloquentCollection
var as well. It might be thatArr::get
evolved over the years or that I am missing some cases so please let me know if I do.The same goes for collecting the model, is that because of expecting potential objects? In that case it would make sense but since the tests did not fail I removed it for now. Let me know when I need to re-add it. No issue at all but can't we use an
(array)
casting to enforce this?Love to hear your feedback.
Cheers mate - we love the plugin,
L