title: How get data in method from others tables?
body: <p><a href="https://i.stack.imgur.com/RfbZs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RfbZs.png" alt="enter image description here"></a></p>
  
  <p>This is my simple db schema. Now in my group table i have 'group_A' and 'group_B'. In questions table i have 10 questions 5 for group_A and 5 for group_B. Users table is one user with ID = 1. What i try to do is get data like this:</p>
  
  <pre><code>SELECT answer
  FROM answers
  JOIN questions q ON (q.id = answer.question_id)
  JOIN group g ON (g.id = q.group_id)
  WHERE user_id = 1 AND g = 'group_A'
  </code></pre>
  
  <p>I have model in users class and i would like create method to get answers depend from group:</p>
  
  <pre><code>public function getAnswers($group) {
          return $this-&gt;hasMany('App\Answers', 'question_id', 'id');
      }
  </code></pre>
  
  <p>How can i get this in that method ? Should i create method group in questions class ?</p>