title: Laravel DB table and eloquent method updateOrCreate
body: <pre><code>    DB::table("mytable")-&gt;updateOrCreate([
        'user_id' =&gt; $user_id,
        'active' =&gt; 1,
        'created_at' =&gt; Carbon::now()
      ]);
  </code></pre>
  
  <p>But this code return me error:</p>
  
  <blockquote>
    <p>Call to undefined method
    Illuminate\Database\Query\Builder::updateOrCreate()</p>
  </blockquote>
  
  <p>So, according to this answer <a href="https://laracasts.com/discuss/channels/laravel/laravel-after-renaming-tables-call-to-undefined-method-updateorcreate" rel="nofollow noreferrer">link</a> (user <em>stanb</em>) I added:</p>
  
  <pre><code>protected $table = 'mytable';
  </code></pre>
  
  <p>And change code:
  <code>DB::table($this-&gt;table)-&gt;updateOrCreate([</code>...</p>
  
  <p>But still I have this same error</p>