I have two database and inside each I have one table:
database_one -> one (table)
database_two -> two (table)
I would like to create a relationship Many-To-Many between two tables inside database_two; but the tables are in two different database.
This is my code for create a pivot table on the same database:
Schema::connection('database_two')->create('one_two', function (Blueprint $table) {
$table->integer('one_id')->unsigned()->nullable();
$table->foreign('one_id')->references('id')
->on('one')->onDelete('cascade');
$table->integer('two_id')->unsigned()->nullable();
$table->foreign('two_id')->references('id')
->on('two')->onDelete('cascade');
$table->timestamps();
});
How can I do?
Thanks!