我试图在我的数据透视表上创建两个外键' image_project
'
(已更新为包含' image_project
')
Schema::create('image_project', function (Blueprint $table) {
$table->integer('image_id')->unsigned();
$table->foreign('image_id')->references('id')->on('images');
$table->integer('project_id')->unsigned();
$table->foreign('project_id')->references('id')->on('projects');
$table->primary(['image_id', 'project_id']);
});
这给了我(在phpmyadmin中查看)是在' project_id'上创建的外键。指的是' id
'在&{39; projects
',但在image_id
上没有这样的事情..
我已经过四重检查,肯定有一个' images
'表与' id
'列是该表的主键。我不明白为什么Eloquent正在处理我为一个人而不是另一个人所做的事情。
根据此处的要求,上述两项迁移是针对' images
'和' projects
'
Schema::create('images', function (Blueprint $table) {
$table->increments('id');
$table->string('display_name', 32);
$table->string('original_filename', 32);
$table->string('filename', 32);
$table->string('caption', 255);
$table->string('mime_type', 32);
$table->timestamps();
$table->softDeletes();
});
Schema::create('projects', function (Blueprint $table) {
$table->increments('id');
$table->string('title', 100);
$table->text('description');
$table->string('type', 10);
$table->timestamps();
$table->softDeletes();
});