我正在使用Laravel6。我想创建一个名为meeting_user
的联接表,该表应该连接表meetings
和users
。考虑到用户可以参加很多会议,而一个会议可以有很多用户。
用户:
Schema::create('users',function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->string('surname');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('username')->unique();
$table->string('password');
$table->enum('permission',array(0,1,2));
$table->enum('is_active',1))->default(1);
$table->rememberToken();
$table->timestamps();
});
会议:
Schema::create('meetings',function (Blueprint $table) {
$table->bigIncrements('id');
$table->text('description');
$table->string('id_room');
$table->date('date');
$table->time('start_hour');
$table->time('end_hour');
$table->enum('is_active',1))->default(1);;
$table->timestamps();
$table->foreign('id_room')->references('id')->on('rooms');
});
我想通过迁移来创建该表,此外,当用户创建与许多用户的会议并向“会议”表中插入新行时,即使是新的“ meeting_user”表也要动态地创建,填写添加新行。 Laravel有办法做到这一点吗?