title: Laravel belongsToMany and Eloquent query
body: <p>I'm trying to get a list of the ID's of the users who read a particular magazine.</p>
  
  <blockquote>
    <p>things table (magazines)</p>
  </blockquote>
  
  <pre><code>id
  name
  </code></pre>
  
  <blockquote>
    <p>thing_progresses</p>
  </blockquote>
  
  <pre><code>id
  progress_value
  </code></pre>
  
  <blockquote>
    <p>thingprogress_thing</p>
  </blockquote>
  
  <pre><code>id
  thing_progress_id (FK from thing_progresses table)
  thing_id (FK from things table)
  user_id (FK from users table)
  </code></pre>
  
  <p>Thing Model</p>
  
  <pre><code>namespace App\Models;
  use Illuminate\Database\Eloquent\Model;
  
  class Thing extends Model
  {
      public function readers() {
          return $this-&gt;belongsToMany('\App\Models\ThingProgress', 'thingprogress_thing');
      }
  }
  </code></pre>
  
  <p>My application</p>
  
  <pre><code>$readers = Thing::with(array('readers' =&gt; function($query) use ($id) {
  $query-&gt;where('thing_progress_id', '1');
  }))-&gt;find($id);
  </code></pre>
  
  <p>View</p>
  
  <pre><code>@foreach($readers as $reader)
      {{$reader-&gt;user_id}}
  @endforeach
  </code></pre>
  
  <p>Here's the error I got.</p>
  
  <pre><code>Trying to get property of non-object (View: /Applications/MAMP/htdocs/master/resources/views/frontend/thing/book/index.blade.php)
  </code></pre>