Composite foreign key Laravel
<p>I'm finding it difficult to create a composite foreign key. I would like a session table that has both 'movieid' and 'cinemaid' as a composite foreign key. This is because one session would require both the movie and the cinema location. </p>

<p>My current schema is the folllowing:</p>

<p>Schema::create('session', function (Blueprint $table) {</p>

<pre><code>$table-&gt;increments('id');
$table-&gt;integer('movieId');
$table-&gt;integer('cinemaId');
$table-&gt;foreign(array('movieId', 'cinemaId'))-&gt;references(array('id', 'id'))-&gt;on(array('movies', 'cinema'));
$table-&gt;dateTime('time');
</code></pre>

<p>});</p>

<p>I can't find much information on how to create composite foreign keys in laravel. The best thing I've found:</p>

<p><a href="http://www.geexie.com/composite-primary-foreign-keys-laravel/" rel="nofollow">http://www.geexie.com/composite-primary-foreign-keys-laravel/</a></p>

<p>However, in this example they pull both foreign keys from one table, where-as in my above example you can see that I need to get data from both the "movies" table and the "cinemas" table. I thought maybe using on(array('movies', 'cinema') would work, but it comes up with the error "Array to string conversion". </p>

<p>I've tried removing the (array()) part, but it doesn't work that way either.</p>

<p>I'd also be happy to hear any alternative solutions if I'm not suppose to be using composite foreign keys. </p>

<p>Thanks a bunch,</p>

<p>Jack. </p>