title: How to increment column with Laravel Eloquent updateOrCreate()?
body: <p>Is it possible to return the model <code>id</code> from the request below ?</p>
  <pre><code>Bar::insert([
    'foo_id' =&gt; Foo::updateOrCreate([
      'code' =&gt; $row[0],
      'name' =&gt; $row[1]
    ])-&gt;increment('count')-&gt;id
  ]);
  </code></pre>
  <p>I also tried this:</p>
  <pre><code>Foo::updateOrCreate([
    'code' =&gt; $row[0],
    'name' =&gt; $row[1]
  ], [
    'count' =&gt; DB::raw('count + 1')
  ])-&gt;id
  </code></pre>
  <p>But it doesn't work at inserting because it <code>count</code> is not yet set.</p>
  <blockquote>
  <p>HINT:  There is a column named &quot;count&quot; in table &quot;foos&quot;, but it cannot be referenced from this part of the query. (SQL: insert into &quot;public&quot;.&quot;foos&quot; (&quot;id&quot;, &quot;name&quot;, &quot;count&quot;) values (123, Hello, count+1) returning &quot;id&quot;)</p>
  </blockquote>
  <p>=== EDIT ===</p>
  <p>With <code>DB::raw('IFNULL(count,0) + 1')</code>, I'm getting:</p>
  <pre><code>  SQLSTATE[42703]: Undefined column: 7 ERROR:  column &quot;count&quot; does not exist
  LINE 1: ... (&quot;code&quot;, &quot;name&quot;, &quot;count&quot;) values ($1, $2, IFNULL(count,0) +...
                                                               ^
  HINT:  There is a column named &quot;count&quot; in table &quot;foos&quot;, but it cannot be referenced from this part of the query. (SQL: insert into &quot;public&quot;.&quot;foos&quot; (&quot;code&quot;, &quot;name&quot;, &quot;count&quot;) values (123, Hello, IFNULL(count,0) + 1) returning &quot;id&quot;)
  </code></pre>