title: laravel eloquent : How to update data if exist
body: <p>I have a table where i have <code>user_id</code> and <code>role_id</code> in it. Now if I select user_id =1 from dropdown and role_id = 2 from dropdown and save it ..Next time if I want to set same user another role instead of creating new row in table..How to update it without creating new one? can anyone suggest something?</p>
  
  <pre><code>$roleUser = RoleUser::firstOrNew(
              ['role_id' =&gt; $request-&gt;Input(['role_id']),
               'user_id' =&gt;$request-&gt;Input(['user_id'])] );
              $roleUser-&gt;save();
  </code></pre>
  
  <p>I used the firstOrNew method but it creates a new entry instead of updating the old one.</p>