title: Undefined variable in phpstorm using laravel . Controller & blade template are provided
body: <p>I'm getting this error message for my code:</p>
  
  <blockquote>
    <p>Undefined variable: questions (View:
    home/xxxx/PhpstormProjects/xxxxx/resources/views/home.blade.php)</p>
  </blockquote>
  
  <p>Please, try to shed some light on what could be wrong. 
  I have provided my <code>QuestionController</code> &amp; question template. Not sure, what my code is missing. Here is my code:</p>
  
  <pre><code>    QuestionController:
  
      &lt;?php
  
  namespace App\Http\Controllers;
  
  use Illuminate\Http\Request;
  use Illuminate\Support\Facades\Auth;
  use App\Question;
  
  class QuestionController extends Controller
  {
      public function __construct()
      {
          $this-&gt;middleware('auth');
      }
  
      public function show(Question $question)
      {
  
          return view('question')-&gt;with('question', $question);
      }
  
  
  
      question.blade.php
  
      @extends('layouts.app')
  
  @section('content')
      &lt;div class="container"&gt;
          &lt;div class="row "&gt;
              &lt;div class="col-md-8"&gt;
                  &lt;div class="card"&gt;
                      &lt;div class="card-header"&gt;Question&lt;/div&gt;
  
                      &lt;div class="card-body"&gt;
  
                          {{$question-&gt;body}}
                      &lt;/div&gt;
                      &lt;div class="card-footer"&gt;
                          &lt;a class="btn btn-primary float-right"
                             href="#"&gt;
                              Edit Question
                          &lt;/a&gt;
  
  
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;div class="col-md-4"&gt;
                  &lt;div class="card"&gt;
                      &lt;div class="card-header"&gt;&lt;a class="btn btn-primary `float-left"`
                                                  href="#"&gt;
                              Answer Question
                          &lt;/a&gt;&lt;/div&gt;
  
                      &lt;div class="card-body"&gt;
                          @forelse($question-&gt;answers as $answer)
                              &lt;div class="card"&gt;
                                  &lt;div class="card-body"&gt;{{$answer-&gt;body}}`&lt;/div&gt;`
                                  &lt;div class="card-footer"&gt;
  
                                      &lt;a class="btn btn-primary float-right"
                                         href="#"&gt;
                                          View
                                      &lt;/a&gt;
  
                                  &lt;/div&gt;
                              &lt;/div&gt;
                          @empty
                              &lt;div class="card"&gt;
  
                                  &lt;div class="card-body"&gt; No Answers&lt;/div&gt;
                              &lt;/div&gt;
                          @endforelse
  
  
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
  @endsection
  
  
  home.blade.php
  
      @extends('layouts.app')
  
  @section('content')
      &lt;div class="container"&gt;
          &lt;div class="row justify-content-center"&gt;
              &lt;div class="col-md-12"&gt;
                  &lt;div class="card"&gt;
                      &lt;div class="card-header"&gt;Questions
  
  
                          &lt;div class="card-body"&gt;
  
                              &lt;div class="card-deck"&gt;
                                  @foreach($questions as $question)
                                      &lt;div class="col-sm-4 d-flex align-items-stretch"&gt;
                                          &lt;div class="card mb-3 "&gt;
                                              &lt;div class="card-header"&gt;
                                                  &lt;small class="text-muted"&gt;
                                                      Updated: {{ $question-&gt;created_at-&gt;diffForHumans() }}
                                                      Answers: {{ $question-&gt;answers()-&gt;count() }}
  
                                                  &lt;/small&gt;
                                              &lt;/div&gt;
                                              &lt;div class="card-body"&gt;
                                                  &lt;p class="card-text"&gt;{{$question-&gt;body}}&lt;/p&gt;
                                              &lt;/div&gt;
                                              &lt;div class="card-footer"&gt;
                                                  &lt;p class="card-text"&gt;
  
                                                      &lt;a class="btn btn-primary float-right" href="{{ route('question.show', ['id' =&gt; $question-&gt;id]) }}"&gt;
                                                          View
                                                      &lt;/a&gt;
                                                  &lt;/p&gt;
                                              &lt;/div&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
                                  @endforeach
                              &lt;/div&gt;
  
                          &lt;/div&gt;
                          &lt;div class="card-footer"&gt;
                              &lt;div class="float-right"&gt;
                                  {{ $questions-&gt;links() }}
                              &lt;/div&gt;
                          &lt;/div&gt;
  
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  @endsection
  </code></pre>