title: Laravel BelongsTo Through relationship
body: <p>How to implement BelongsToThrough Relationship in Laravel? </p>
  
  <p>I have Table: </p>
  
  <pre><code>**projects_table**
  id 
  
  **categories_table**
  id
  project_id 
  
  **properties_table**
  id
  category_id
  </code></pre>
  
  <blockquote>
    <p>Category BelongsTo Project  </p>
  </blockquote>
  
  <pre><code>public function project(){
      return $this-&gt;belongsTo('App\Project');
  }
  </code></pre>
  
  <blockquote>
    <p>Property BelongsTo Category</p>
  </blockquote>
  
  <pre><code>public function category(){
      return $this-&gt;belongsTo('App\Category');
  }
  </code></pre>
  
  <p><strong>How can we make a relationship?</strong> </p>
  
  <blockquote>
    <p>Property BelongsTo Project Through Category</p>
  </blockquote>
  
  <pre><code>public function project(){
       return $this-&gt;belongsToThrough('App\Project', 'App\Category');
  }
  </code></pre>
  
  <p><strong><em>EDIT QUESTION.</em></strong> </p>
  
  <p>Because I want to do multi-tenancy on my application, and the tenancy is PORJECT. I want to separate Category and Property by Project.</p>
  
  <p>CATEGORY is belongsTo PROJECT
  PROPERTY is belongsTo CATEGORY </p>
  
  <p>so I want to make relationship between PROPERTY and PROJECT via CATEGORY.
  for now, I need to add: <code>project_id</code> on both <strong>categories</strong> and <strong>properties</strong> tables and I think that this is not the right way.  </p>