Making visible or hidden attributes from Eloquent temporarily
— Laravel — 1 min read
From Laravel news Instagram , I saw useful methods from underlying eloquent. For example, we have hidden two fields, address and phone_number, but now we need to show them.
The makeVisible method makes visible attributes that are typically ‘hidden’ on each model in the collection:
On the other hand, address and phone_number are visible, we need hiding them for now.
The makeHidden method hides attributes that are typically ‘visible’ on each model in the collection:
It’s pretty useful.