title: laravel one-to-many on pivot table
body: <p>I have a four table which are institutions, forms, form_institution(pivot table) and form_institution_attributes. Here is migrations :</p>
  
  <p>Institution Table :</p>
  
  <pre><code>public function up() {
       Schema::create('institutions', function (Blueprint $table) {
           $table-&gt;increments('id');
           $table-&gt;string('name', 255);
           $table-&gt;softDeletes();
           $table-&gt;timestamps();
       });
   }
  </code></pre>
  
  <p>Institution model : </p>
  
  <pre><code>public function forms() {
      return $this-&gt;belongsToMany(Form::class, 'form_institution');
  }
  </code></pre>
  
  <p>Form Table : </p>
  
  <pre><code>public function up() {
      Schema::create('forms', function (Blueprint $table) {
          $table-&gt;increments('id');
          $table-&gt;string('name', 255);
          $table-&gt;softDeletes();
          $table-&gt;timestamps();
      });
  }
  </code></pre>
  
  <p>Form Model :</p>
  
  <pre><code>public function institutions() {
      return $this-&gt;belongsToMany(Institution::class, 'form_institution');
  }
  </code></pre>
  
  <p>Form Institution Pivot Table :</p>
  
  <pre><code>Schema::create('form_institution', function (Blueprint $table) {
      $table-&gt;increments('id');
      $table-&gt;integer('institution_id')-&gt;unsigned();
      $table-&gt;integer('form_id')-&gt;unsigned();
  
      $table-&gt;foreign('institution_id')-&gt;references('id')-&gt;on('institutions');
      $table-&gt;foreign('form_id')-&gt;references('id')-&gt;on('forms');
  });
  </code></pre>
  
  <p>Everything is ok till here. But i need to add one more table which is attribute table and it's relationship between pivot table (one-to-many)</p>
  
  <p>Here is table :</p>
  
  <pre><code>Schema::create('form_institution_attributes', function (Blueprint $table) {
              $table-&gt;increments('id');
              $table-&gt;integer('form_institution_id')-&gt;unsigned();
              $table-&gt;integer('field_name_id')-&gt;unsigned();
              $table-&gt;integer('input_type_id')-&gt;unsigned();
              $table-&gt;string('field_caption');
              $table-&gt;softDeletes();
              $table-&gt;timestamps();
  
              $table-&gt;foreign('form_institution_id')-&gt;references('id')-&gt;on('form_institution');
          });
  </code></pre>
  
  <p>Now, when i call the institution table and institution->forms parameter, i want to get form_institution_attribute (sub-table) with pivot table. But i couldn't do this ?</p>
  
  <p>How can i add table under pivot table as a one-to-many relation ?</p>