You said that dealing with an attitude has a lot through , which, as I understand it, requires the work of 3 separate models. I feel that you are working with a ratio from many to many , since only you are working with two models.
As you said, you come from the Rails background, I feel that I am either making a huge mistake, or I don’t understand your relationship with db, or you have a lot, and many of them are confused.
FYI: Enough, from laravel docs:
The has-many-through relationship provides a convenient short distance to access distance relationships through an intermediate relationship. For example, a country model can have many Post models through an intermediate user model.
More details here: https://laravel.com/docs/5.2/eloquent-relationships#has-many-through
and from many to many: https://laravel.com/docs/5.2/eloquent-relationships#many-to-many
If you work with many for many, I believe that your database schema should consist of three tables:
deals , faqs and the faqs staging table, the third table name follows the laravel conventions for the staging table, where the singular names of the linked tables are used in alphabetical order with underscores in between. For the deal_faq table, deal_id and faq_id .
Then you will need two models (only two, not three)
Deal and Faq with the following methods:
Deal Model:
public function faqs(){ return $this->belongsToMany('App\Deal'); }
Faq Model:
public function deals(){ return $this->belongsToMany('App\Faq'); }
Now, to use them, you can do the following, for example:
// get a deal $deal = App\Deal::first(); // grab the first one in the db // get faqs linked to deal $deal->faqs; // connect an faq and deal together $faq = App\Faq::first(); $deal->attach($faq->id); // where id is the primary key attribute
Note that this answer assumes that you perform laravel settings when defining relationships.
And I am very sorry that I do not completely understand this part of your question: "How do I display the faqs, but submit them through the form so that I can check the relationship in the controller by presentation?"
I assume that you are asking if I can represent Faq in a form, how can I capture a Faq relationship. In this case, you can do something similar if you use the Faq id in your form request.
$faqId = $request->faq_id; $faq = App\Faq::find($faqId); $deals = $faq->deals;
As you have not shown a lot of code, it's hard to say, and I made a lot of assumptions. In any case, I hope this helps, and if you need any further clarification, please ask and provide more detailed information about your code, if you can.