title: Create App Quiz Using Laravel 7 and Mysql
body: <p>i'm trying to create a simple Quiz App with Laravel and Mysql .</p>
  <p>the idea is , i'm stucked on the relattions between questions/options .</p>
  <p>first i create a table called &quot;quiz&quot;</p>
  <pre><code>ID  name
  1   Brazil
  2   EUA
  3   Japan
  </code></pre>
  <p>a table called &quot;questions&quot;</p>
  <pre><code>ID  quiz_id name
  1   1   President ?
  2   1   Food?
  3   1   Music?
  4   1   Maiority?
  </code></pre>
  <p>and a table called &quot;options&quot;</p>
  <pre><code>ID  question_id name
  1   1   lula    
  2   1   bolsonaro   
  3   2   rice
  4   2   beans
  5   3   samba
  6   3   rock    
  7   4   black
  8   4   white
  </code></pre>
  <p>like image below , i receive the questions related with quiz . my function on my HomeController looks like this .</p>
  <pre><code>public function index(){
  
  
      $quiz = Quiz::where('id',1)-&gt;with('questions')-&gt;get();
      $array = array('quiz' =&gt;$quiz);
  
  
  
  
          return $array;
  
  }
  </code></pre>
  <p>and my model Quiz have this relationship</p>
  <pre><code>public function questions(){
      return $this-&gt;hasMany('App\quizquestion', 'quiz_id');
  }
  </code></pre>
  <p>but i wanna make a relation of questions with options .</p>
  <p>i'm thinking that must be another sub object inside questions . like a thirty leve .</p>
  <p>Example :</p>
  <p>quiz
  questions
  options.</p>
  <p>because i wanna call this on my blade template , actualy i 'm calling this way</p>
  <pre><code>&lt;body&gt;
  
  
      @foreach($quiz as $item)
  
          &lt;h1&gt;{{$item-&gt;name}}&lt;/h1&gt;
  
         @foreach($item-&gt;questions as $quest)
         &lt;p&gt;{{$quest-&gt;question}}&lt;/p&gt;
          @endforeach
           @endforeach
  
  
  
  
  
  &lt;/body&gt;
  </code></pre>
  <p>that return me :</p>
  <p>Brazil</p>
  <p>President ?</p>
  <p>Food ?</p>
  <p>Music ?</p>
  <p>Maiority?</p>
  <p><a href="https://i.stack.imgur.com/VEN6w.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VEN6w.png" alt="enter image description here" /></a></p>