title: Pluck childrens child only in Laravel
body: <p>I want to <strong>select</strong> <code>brand</code> <code>name</code> only from <code>$collect</code>, what can I do to achieve that?</p>
  
  <p>Current:</p>
  
  <pre><code>$collect = collect([
      0 =&gt; [
          ['name' =&gt; 'iPhone 6S', 'brand' =&gt; ['name' =&gt; 'Apple', 'type' =&gt; 'brand', 'id' =&gt; 1]],
      ],
      1 =&gt; [
          ['name' =&gt; 'Galaxy S7', 'brand' =&gt; ['name' =&gt; 'Samsung', 'type' =&gt; 'brand', 'id' =&gt; 2]],
      ],
  ]);
  </code></pre>
  
  <p>Expected result:</p>
  
  <pre><code>$collect = collect([
      0 =&gt; [
          ['name' =&gt; 'iPhone 6S', 'brand' =&gt; ['name' =&gt; 'Apple']],
      ],
      1 =&gt; [
          ['name' =&gt; 'Galaxy S7', 'brand' =&gt; ['name' =&gt; 'Samsung']],
      ],
  ]);
  </code></pre>
  
  <h1>EDIT</h1>
  
  <p>I tried using map() and each() collections provided by laravel, but none of them help.</p>
  
  <h1>EDIT (ROSS)</h1>
  
  <p>This worked:</p>
  
  <pre><code>  $collect-&gt;transform(function ($item) {
      $itemData = collect($item);
        return $itemData-&gt;transform(function ($item, $key) {
          if($key == 'brand') {
            $item = array_only($item, 'name');
          }
          return $item;
        });
    });
  </code></pre>