Hide children field when serializing toArray [Laravel 5.3]
<p>I've read <a href="https://laravel.com/docs/5.3/eloquent-serialization" rel="nofollow">here</a> (Section: <em>Temporarily Modifying Attribute Visibility</em>) that we can hide object properties temporarily.</p>

<p>Is it possible to also hide children attributes?</p>

<p>For example:</p>

<pre><code>//User model
class User extends \App\AppModel
{
    public function articles()
    {
        return $this-&gt;hasMany(Article::class);
    }
}
</code></pre>

<p>Exclude from array here:</p>

<pre><code>$user = User::find($id);

$userData = $user-&gt;makeHidden(['last_name', 'articles.*.user_id'])-&gt;toArray();
dd($userData); //user_id still present in articles :(
</code></pre>