title: How to fix 'undefined variable: title' in Laravel
body: <p>I'm trying to include data from two different tables in MySQL onto one view using Laravel. The 'questions' data shows but the 'questionnaire' data does not, hence the "undefined variable: title". I have tried looking online for ages but none of the solutions seem to solve my problem.</p>
  
  <p>I've already tried loading them in the same view but I am not sure if I am doing it correctly as I am extremely new to Laravel!</p>
  
  <p>index.blade.php file:</p>
  
  <pre class="lang-php prettyprint-override"><code>@foreach($question as $questionnaire)
          &lt;h4&gt;{{ $questionnaire-&gt;title }}&lt;/h4&gt;
      @endforeach
  </code></pre>
  
  <p>QuestionsController file:</p>
  
  <pre class="lang-php prettyprint-override"><code>public function index()
      {
        $question = questions::all();
        $questionnaire = questionnaires::all();
        return view('question.index',compact('question', 'questionnaire'));
      }
  </code></pre>
  
  <p>The title of the questionnaire should appear on the index page along with the questions. The questions feature works as expected so nothing needs to be touched on that part. </p>
  
  <p>Any help/support would be greatly appreciated.</p>