I came to an unexpected result when using makeVisible method and not making the attributes I passed visible, so I saw that the reason was that the method will only make visible the fields if them are in the 'hidden' property.
Model.php
protected $visible = ['remaining', 'restored_at'];
// id not returned
$model->all()->makeVisible(['id'])->toArray();
Instead having Model.php
protected $hidden = ['id'];
// id returned
$model->all()->makeVisible(['id'])->toArray();
The easy workaround would be using hidden property but I'm making a package and I need to get a full properties toArray() no matter which property the user uses.
Is this the expected behaviour?
Ping @taylorotwell.
I was facing the same problem. I ended using the hidden property.
In my opinion makeVisible should... make visible the passed attributes, so yes, weird behaviour.
....I've run into this bug too...
debug for a total afternoon!
thks @marcmascarell
Fix already merged.
Will be available in the next release.
Most helpful comment
Ping @taylorotwell.