title: Laravel : Trying to get property of non-object
body: <p>I have problem with laravel , in my localhost everthing is fine but on my shared hosting i got problem even is the same php version </p>
  
  <p>For example : 
  I want to get question title using $answer->question->title but i got error Trying to get property of non-object (View: /new/resources/views/users/show.blade.php)
  But the project work fine in my localhost</p>
  
  <p>Controller : </p>
  
  <pre><code>public function show($id)
      {
          $user = User::find($id);
          $answers = \App\Answer::where('user_id','=',$user-&gt;id)
                                  -&gt;with(['survey'])
                                  -&gt;get();
          $survey = \App\Survey::pluck('title', 'id')-&gt;toArray();
          $question = \App\Question::pluck('title', 'id')-&gt;toArray();
  
              return view('users.show', compact('user','survey','answers','question'));
      }
  </code></pre>
  
  <p>View blade :</p>
  
  <pre><code> &lt;table class="table"&gt;
                                  &lt;thead class="thead-light"&gt;
                                      &lt;tr&gt;
                                          &lt;th&gt;{{ __('Question') }}&lt;/th&gt;
                                          &lt;th&gt;{{ __('Answers') }}&lt;/th&gt;
                                          &lt;th&gt;{{ __('Creation Date') }}&lt;/th&gt;
                                      &lt;/tr&gt;
                                  &lt;/thead&gt;
                                  &lt;tbody&gt;
                                      @foreach($answers as $t)
                                      &lt;tr&gt; 
                                          &lt;td&gt; {{ $t-&gt;question-&gt;id }} &lt;/td&gt;
                                          &lt;td&gt; {{ $t-&gt;answer }} &lt;/td&gt;
                                          &lt;td&gt; {{$t-&gt;created_at}} &lt;/td&gt;
                                      &lt;/tr&gt;
                                      @endforeach
                                  &lt;/tbody&gt;
                              &lt;/table&gt;
  </code></pre>
  
  <p>In my localhost is working fine but in shared hosting i got : </p>
  
  <p>ErrorException (E_ERROR)
  Trying to get property of non-object (View: /new/resources/views/users/show.blade.php)
  Previous exceptions
  Trying to get property of non-object (0)</p>
  
  <p>Please could you help me to fix that ?</p>