title: Laravel eloquent querying with multiple relationships
body: <p>I have four tables which is <code>departments</code>, <code>users</code>, <code>items</code>, <code>items_inventories</code></p>
  
  <p>The relationship is like this:</p>
  
  <p>A <code>user</code> has a assigned <code>department</code>.
  An <code>item</code> has a assigned <code>department</code>. <code>item_inventories</code> has many items.</p>
  
  <p>Structure:</p>
  
  <pre><code>users
  -&gt;id
  -&gt;name
  -&gt;password
  -&gt;access_type (department_id)
  
  departments
  -&gt;id
  -&gt;name
  
  items
  -&gt;id
  -&gt;name
  -&gt;department_id
  
  items_inventories
  -&gt;id
  -&gt;item_id
  -&gt;qty
  </code></pre>
  
  <p>My models:</p>
  
  <pre><code>class Item extends Model
  {
      public function department()
      {
          return $this-&gt;hasOne('App\Http\Models\Department', "id", "department_id");
      }
  }
  
  
  class ItemsInventory extends Model
  {
      public function item()
      {
          return $this-&gt;hasOne('App\Http\Models\Item', "id", "item_id");
      }
  }
  </code></pre>
  
  <p>In my <code>items_inventories</code> how do I query all items that belongs to a specific department? Since <code>items</code> has already a relationship to <code>departments</code>, How do I query like: select all items in items_inventories where item department_id is equal to 3?</p>
  
  <p>My goal is, I have a user who is logged in, and I can access the assigned department to him/her via <code>access_type</code> (department_id) when my page loads, I want to list only items in the <code>items_inventories</code> that is assigned to his/her department. I already checked: <code>https://laravel.com/docs/5.4/eloquent-relationships#relationship-methods-vs-dynamic-properties</code> but can't seem to find something that matches my requirement. Thanks</p>