title: Laravel: How to add a column to a query?
body: <p>I need you help. I'm trying to add a column to each query of an specific eloquent model.</p>
  
  <p>Basically I want to add this:</p>
  
  <pre><code>COALESCE(name, network_name) AS name
  </code></pre>
  
  <p>It's important to keep the previously selected fields so I tried this in my model:</p>
  
  <pre><code>public function newQuery()
  {
      $query = parent::newQuery()-&gt;addSelect('name'); // it's name only for testing purposes
  
      return $query;
  }
  </code></pre>
  
  <p>But this doesn't add the column. It replaces it. So instead of getting something like:</p>
  
  <blockquote>
    <p>select *, <code>name</code> from <code>programs</code> where <code>programs</code>.<code>id</code> = ? limit 1</p>
  </blockquote>
  
  <p>I get:</p>
  
  <blockquote>
    <p>select <code>name</code> from <code>programs</code> where <code>programs</code>.<code>id</code> = ? limit 1</p>
  </blockquote>
  
  <p>What am I doing wrong? I haven't found anything on the net so I really hope you can help me!</p>