Laravel Eloquent many-to-many relationship: Use explicit pivot table
<p>How can I select an explicit table (with migration and model) as pivot table?</p>

<p>My models are</p>

<pre><code>User
-id

Role
-id

user_role
-user_id
-role_id
-other_foreign_key_id
-other_attributes
-...
</code></pre>

<p>I know how many-to-many relations work in laravel in general. But in the documentation they only use the automatic generated joining table where I can't define an additional foreign key constraint or datatypes for additional columns. </p>

<p>What I want is that I have my own migration and model for the user_role table and use that as pivot but I don't know how to explicit link a defined table as pivot to a m-to-n relation.</p>

<p>Thanks in advance.</p>