Skip to content

Yish

Making visible or hidden attributes from Eloquent temporarily

Laravel1 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.

makeVisible($attributes)

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.

makeHidden($attributes)

The makeHidden method hides attributes that are typically ‘visible’ on each model in the collection:

It’s pretty useful.