Almost, we set the fields visible or hidden by two properties from eloquent, but sometimes we need to show specific fields temporarily, how do we do?
From Laravel news Instagram, I saw useful methods from underlying eloquent.
For example, we have hidden two fields,
phone_number, but now we need to show them.
makeVisible method makes visible attributes that are typically ‘hidden’ on each model in the collection:
$users = $users->makeVisible(['address', 'phone_number']);
On the other hand,
phone_number are visible, we need hiding them for now.
makeHidden method hides attributes that are typically ‘visible’ on each model in the collection:
$users = $users->makeHidden(['address', 'phone_number']);
It’s pretty useful.