title: Laravel Eloquent: hasManyThrough Many to Many relationship
body: <p>I have the following classes (simplified here) in my Laravel 5.7 model:</p>
  
  <p>VEHICLE.PHP</p>
  
  <pre><code>&lt;?php
  
  namespace App;
  
  use Illuminate\Database\Eloquent\Model;
  
  class Vehicle extends Model
  {
  
      public function journeys()
      {
          return $this-&gt;hasMany('App\Journey');
      }
  
  }
  </code></pre>
  
  <p>JOURNEY PHP</p>
  
  <pre><code>&lt;?php
  
  namespace App;
  
  use Illuminate\Database\Eloquent\Model;
  
  class Journey extends Model
  {
  
      public function vehicle()
      {
         return $this-&gt;belongsTo('App\Vehicle');
      }
  
      public function users()
      {
          return $this-&gt;belongsToMany('App\User');
      }
  }
  </code></pre>
  
  <p>USER.PHP</p>
  
  <pre><code>&lt;?php
  
  namespace App;
  
  use Illuminate\Database\Eloquent\Model;
  
  class User extends Model
  {  
  
      public function journeys()
      {
          return $this-&gt;belongsToMany('App\Journey');
      }
  }
  </code></pre>
  
  <p>I have an intermediate table (journey_user) between users and journeys (see schema attached).</p>
  
  <p><a href="https://i.stack.imgur.com/7KZar.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7KZar.png" alt="enter image description here"></a></p>
  
  <p>I can easily get all journeys made by a particular user. But <strong>how can I get all vehicles used by a particular user?</strong> The standard hasManyThrough method does not appear to work because of the Many to Many relationship between users and journeys.</p>
  
  <p>Thanks for your help!</p>