title: Laravel UpdateOrCreate
body: <p>I'm trying to if there are records just update and if there are not records just create. Problem is: </p>
  
  <blockquote>
    <p>Already has records case: It creates records when there are already have record in database.</p>
  </blockquote>
  
  <pre><code>public function store(Request $request)
      {
          $time = $request-&gt;input('time');
          foreach ($request-&gt;input('number') as $key =&gt; $value) {
              Choice::UpdateOrCreate([
                  'user_id' =&gt; Auth::id(),
                  'time'  =&gt; $time,
                  'topic_id' =&gt; $key,
                  'question_number' =&gt; $value,
              ]);
          }
      }
  </code></pre>