Laravel makeHidden (how to use) I am using Laravel 5.3, and currently working on models.

I have the following code:

$result = TheEpisode::find($id)-&gt;with('TheParts')-&gt;take(1)-&gt;get()-&gt;each(function ($item) {
      $item-&gt;TheParts-&gt;makeHidden("title");
});


The purpose of this code is to display all the data from TheEpisode and TheParts, but exclude the title from there.

Can this be improved, like not using a loop to exclude the title attribute?
no need to loop as you are using find method and find method always give single result

$result = TheEpisode::find($id);
$result-&gt;TheParts-&gt;makeHidden("title");
dd($result-&gt;toArray());