I have configured Laravel 5.2 to contain 2 database connections. I know how I can connect to each one within my controllers, models etc. The only thing I am unsure of is the following.
System A has a users table which contain all the users of system A.
I am now working within System B. System B has its own users table with all the users of System B. System B need to get a list of users in System A.
This is where the problem is. For system B I am creating my migration. System B allows for users of this system to create a project so my migration is as follows
Schema::create('projects', function (Blueprint $table) {
$table->increments('id');
$table->string('projectName')->default('');
$table->string('projectValue')->default('');
$table->integer('user_id')->unsigned()->default(0);
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->integer('systemA_user_id')->unsigned()->default(0);
$table->foreign('systemA_user_id')->references('id')->on('users')->onDelete('cascade');
$table->engine = 'InnoDB';
});
By doing the following, I can link the project in System B to a User in System B.
$table->integer('user_id')->unsigned()->default(0);
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
However, although this project is created in System B, it is for a user in System A. Therefore I have added the following
$table->integer('systemA_user_id')->unsigned()->default(0);
$table->foreign('systemA_user_id')->references('id')->on('users')->onDelete('cascade');
The problem is that it is currently referencing the System B users table. What I need it to do is reference the System A users table.
Would something like this be possible?
Thanks