title: Laravel: get name from table users
body: <p>I need get the name field in user table</p>
  
  <p>My method in the controller:</p>
  
  <pre><code>public function reviewsactivity()
  {
      $activity = Activity::orderBy('id', 'DESC')-&gt;paginate();
      $users = User::orderBy('id', 'ASC')-&gt;pluck('id', 'name');
      return view('reviews.reviewsactivity', compact('activity', 'users'));
  }
  </code></pre>
  
  <p>And the view:</p>
  
  <pre><code>              @foreach($activity as $actividad)
                    &lt;tr&gt;
                        &lt;td&gt;{{ $actividad-&gt;description }}&lt;/td&gt;
                        &lt;td&gt;{{ $actividad-&gt;subject_type }}&lt;/td&gt;
                        &lt;td&gt;{{ $actividad-&gt;user-&gt;name }}&lt;/td&gt;
                        &lt;td&gt;{{ $actividad-&gt;causer_type }}&lt;/td&gt;
                        &lt;td&gt;{{ date('d-m-Y', strtotime($actividad-&gt;created_at)) }}&lt;/td&gt;
                    &lt;/tr&gt;
                @endforeach
  </code></pre>
  
  <p>The field in the Activity table: causer_id</p>
  
  <p>And I have the next log:</p>
  
  <pre><code> Trying to get property of non-object 
   (View: C:\laragon\www\tao\resources\views\reviews\reviewsactivity.blade.php)
  </code></pre>