How to create a form for hasManyThrough relationship, with pivot, in a Laravel5 view
<p>I am coming from a Rails background where we can create has_many_through pretty easily with the right references.</p>

<p>My models in this project: Deal  &lt;=> DealsFaqs &lt;=> Faqs</p>

<p>In the Deals model I have:</p>

<pre><code>    public function faqs(){
        return $this-&gt;hasManyThrough('App\Faq', 'App\DealsFaqs');
    }
</code></pre>

<p>DealsFaqs has:</p>

<pre><code>    public function deals()
    {
        return $this-&gt;belongsTo('App\Deal');
    } 

     public function faqs()
     {
         return $this-&gt;belongsTo('App\Faq');
     }
</code></pre>

<p>and my Faq model has:</p>

<pre><code>    public function deals(){
        return $this-&gt;hasManyThrough('App\Deal', 'App\DealsFaqs');
    }
</code></pre>

<p>A deal needs to be able to be associated with N faqs. </p>

<p>So I created a table for DealsFaqs that has a deal_id and a faq_id fields.  </p>

<p>I am easily able to list the FAQ's on the Deal form page, but that isn't tied to the DealsFaqs.  </p>

<p>How do I output the faqs but submit them through the form in a way that I can then check the relationship in the controller on submission?</p>

<p>--- EDIT BASED ON REQUEST FOR MORE CODE AND DETAIL:</p>

<p>Ultimately there will be roughly 20-30 faqs.  And a growing number of deals.  As the admin creates each deal they need to select which FAQ's are relevant to the deal. Some will be relevant and others won't be.  Then those FAQ's will be output to the page.  </p>

<p>I assumed I needed a hasManyThrough because  I can't just put a single faq_id field on the Deal as it needs many and the same on the FAQ.  FAQ's belong to many deals.</p>

<p>My DealCreate Method in the Controller:</p>

<pre><code>    ///////////////////
    // ASSOCIATE FAQ's TO DEALS
    ///////////////////
    if($request-&gt;faqs){
        foreach($request-&gt;faqs as $key =&gt; $faq){

            // Create new DealsFaqs
            $entry = new \App\DealsFaqs;

            // Populate it
            $entry-&gt;faq_id = $faq['id']; 
            $entry-&gt;deal_id = $deal-&gt;id;            

            $entry-&gt;save(); // Save the DealsFaqs
        }
    }
</code></pre>

<p>Then my current form section to relate FAQ's to deals:</p>

<pre><code>       &lt;?php $a=0; foreach($faqs as $faq): ?&gt;
        &lt;div class="col-sm-12"&gt;
            &lt;label&gt;
                &lt;input type="radio" name="faqs[{{ $a }}][id]" value="{{ $faq-&gt;id }}"&gt;
                {{ $faq-&gt;name }} 
            &lt;/label&gt;
        &lt;/div&gt;
        &lt;?php $a++; endforeach; ?&gt;
</code></pre>

<p>When I select 1 or all of them a new relationship is created on the deals_faqs table I created. But then for obvious reasons (I don't know how to solve) But the radios don't know to stay checked, and I don't know how to access/update in the controller.  ALSO is this the right way to do this or am I wrong with the relationships? </p>