Vigyata.AI
Is this your channel?
GithubGithub00

08 Add setVisible and setHidden to Eloquent Collection

This PR adds setVisible() and setHidden() to the Eloquent Collection, which is exactly what I demo in Tinker. It’s a clean way to shape model output after you already have the collection, especially when you didn’t build the query yourself.

Buy on Github

You'll be taken to Github to complete your purchase.

Pros

  • +Lets you include only specific attributes with setVisible() on Eloquent collections
  • +Lets you exclude attributes with setHidden() without changing the original query
  • +Useful when you receive a collection from another part of the app

Cons

  • -Does not work on a normal Illuminate Collection

Featured in this video