title: Transform laravel collection
body: <p>I need a certain array format like this:</p>
  
  <pre><code>    $data = [
          1 =&gt; ['order' =&gt; 3],
          2 =&gt; ['order' =&gt; 2],
          3 =&gt; ['order' =&gt; 1]
      ];
  </code></pre>
  
  <p>So when I do:</p>
  
  <pre><code>    $ids = $items-&gt;transform(function ($item) {
          return [$item-&gt;id =&gt; ['order' =&gt; rand(1,10)]];
      })-&gt;all();
  </code></pre>
  
  <p>Gives:</p>
  
  <pre><code>array:3 [
    0 =&gt; array:1 [
      1 =&gt; array:1 [
        "order" =&gt; 8
      ]
    ]
    1 =&gt; array:1 [
      2 =&gt; array:1 [
        "order" =&gt; 3
      ]
    ]
    2 =&gt; array:1 [
      3 =&gt; array:1 [
        "order" =&gt; 10
      ]
    ]
  ]
  </code></pre>
  
  <p>How can I transform the array in a specific way I need above? TIA</p>