我正在尝试在 Laravel 中创建多对多的以下关系。到目前为止,我发现所有的解决方案,例如这个Laravel 关注者/关注关系,都是用户可以关注个人资料的地方。在我的情况下,一个用户可以有很多个人资料,所以我想这样做,以便个人资料可以跟随个人资料。
我是 Laravel 的新手,被告知有一个命名约定。我创建了迁移
php artisan make:migration creates_profile_profile_pivot_table --create profile_profile
这是我的架构
public function up()
{
Schema::create('profile_profile', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('profile_id');
$table->unsignedBigInteger('profile_id');
$table->timestamps();
});
}
我得到错误
Illuminate\Database\QueryException : SQLSTATE[HY000]: General error: 1 duplicate column name: profile_id (SQL: create table "profile_profile" ("id" integer not null primary key autoincrement, "profile_id" integer not null, "profile_id" integer not null, "created_at" datetime null, "updated_at" datetime null))
如果我将两个 profile_id 替换为 following_id 和 follower_id 会与命名约定冲突吗?
慕沐林林
幕布斯6054654
随时随地看视频慕课网APP