title: Laravel - pluck with specified keys
body: <p>I have a line of code similar to the following:</p>
  
  <pre><code>Sport::pluck('id', 'name)
  </code></pre>
  
  <p>I am dealing with frontend JavaScript that expects a list in this format:</p>
  
  <pre><code>var list = [
   { text: 'Football', value: 1 },
   { text: 'Basketball', value: 2 },
   { text: 'Volleyball', value: 3 }
   ...
  ]
  </code></pre>
  
  <p>I am trying to figure out how I can somehow transform the <code>id</code> and <code>name</code> values that I pluck from my model to a format similar to the Javascript <code>list</code>.</p>
  
  <p>If that's unclear, I am looking to end up with an associative array that contains two keys: <code>text</code> and <code>value</code>, where <code>text</code> represents the <code>name</code> field on my model, and where <code>value</code> represents the <code>id</code> of the model - I hope this makes sense.</p>
  
  <p>How would I approach this?</p>
  
  <p>I initially tried something like this (without checking the documentation)</p>
  
  <pre><code>Sport::pluck(["id" =&gt; "value", "name" =&gt; "text]);
  
  </code></pre>
  
  <p>But that isn't how you do it, which is quite clear now. I've also tried some map-related snippet, which I cannot seem to Ctrl-z to. </p>
  
  <p>Any suggestions?</p>