title: Eloquent mapping API attributes to field names
body: <p>I have an app that sends to an API an object like this:</p>
  
  <pre><code>{id: 4, foo_id: 4, numberOfBars: 2}
  </code></pre>
  
  <p>The Laravel backend has a database table with fields like this:</p>
  
  <pre><code>id, foo_id, number_of_bars
  </code></pre>
  
  <p>I'm currently mapping the API keys to table names in an array, like so:</p>
  
  <pre><code>$map = [
      'id' =&gt; 'id',
      'foo_id' =&gt; 'foo_id',
      'numberOfBars' =&gt; 'number_of_bars'
  ];
  </code></pre>
  
  <p>and using this to create a new load of data to pass to the Eloquent model. This seems inefficient. Is there a way to do this more efficiently in Eloquent? I can't create a catch-all method because as you see some keys are in camelCase and some aren't.</p>