title: Trying to get property of non-object Laravel 5.4
body: <p>Hi Guy's Im always getting an error from laravel 5.4.
  Im creating a list of members... but when i use @foreach it says</p>
  
  <pre><code>ErrorException in 6163a8b030c7474bc8eaad359ab99eb61ebdb127.php line 38:
  Trying to get property of non-object (View: E:\wamp64\www\gplspring2017\resources\views\admin\memberlist.blade.php)
  </code></pre>
  
  <p>Here's my controller</p>
  
  <pre><code>public function listmember(Request $request, $idteam)
  {
      $teams = DB::table('gpl_team')-&gt;where('gpl_team_id', $idteam)-&gt;first();
      $count = count($teams);
  
      if (!$count) {
          return redirect('404');
      } else {
          return view('/admin/memberlist', ['team' =&gt; $teams]);
      }
  }
  </code></pre>
  
  <p>and here's my view code:</p>
  
  <pre><code>&lt;table class="table table-striped"&gt;
      &lt;tr&gt;
          &lt;td style="width:15%;"&gt;&lt;/td&gt;
          &lt;td style="width:25%;"&gt;Summoners Name&lt;/td&gt;
          &lt;td style="width:25%;"&gt;Name&lt;/td&gt;
          &lt;td style="width:25%;"&gt;Role&lt;/td&gt;
          &lt;td style="width:10%;"&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;?php
      $qmember = DB::table('team_member')-&gt;where('gpl_team_id', $team-&gt;gpl_team_id)-&gt;first();
  
      $counting = count($qmember);
  
      ?&gt;
      @if (! $counting)
      &lt;tr&gt;
          &lt;td colspan="4"&gt; No Recored! &lt;/td&gt;
      &lt;/tr&gt;
      @else
      @foreach($qmember as $get_member)
      &lt;tr&gt;
          &lt;td&gt;&lt;img src="{{ $get_member-&gt;member_pic }}" /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;
              &lt;a href="" data-toggle="tooltip" title="Edit Team"&gt;&lt;div class="glyphicon glyphicon-pencil"&gt;&lt;/div&gt;&lt;/a&gt; |
              &lt;a href="" data-toggle="tooltip" title="Delete Team"&gt;&lt;div class="glyphicon glyphicon-trash"&gt;&lt;/div&gt;&lt;/a&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
      @endforeach
      @endif
  &lt;/table&gt;
  </code></pre>
  
  <p>When i remove the foreach the code is working.. but i try to add the <code>@foreach($qmember as $get_member)</code> it not working anymore...</p>