title: Calculate First answer from user and ignore others, by Using Laravel Eloquent
body: <p>If a User attempt a question more than one time then i want to sum only first answer in the total and want to ignore other answers of same question, how can we do that by using eloquent method. Right now i am using following code that calculate all values included repeated answers. How can we subtract repeated answers from total?</p>
  
  <pre><code>$total_score = User::find($user-&gt;id)-&gt;testsresult-&gt;sum('correct');
  </code></pre>
  
  <p>Below is database structure</p>
  
  <p><a href="https://i.stack.imgur.com/yE3sQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yE3sQ.png" alt="enter image description here"></a></p>