platform icon indicating copy to clipboard operation
platform copied to clipboard

BugFix Trait AsSource

Open ivanomatteo opened this issue 4 years ago • 0 comments

The trait is part of the model class, so can access also to private and protected members. For example if we use this trait on a model with a nullable database field called "visible"

Arr::get($this->toArray(), $field) ---> is null Arr::get($this->getRelations(), $field) ---> is null $this->$field ---> refear to "protected $visible = []"

with this commit the problem is solved, and anso bring a performance improvement: ->toArray() force the execution of all casts and accessors, but only one filed is requested.

ivanomatteo avatar Dec 01 '21 11:12 ivanomatteo