如何定义下表之间的关系。
Class->belongsToMany('Student');
Student->belongsToMany('Class');
由 class_student 表旋转的班级表和学生表
我有如下付款表
$table->increments('id');
$table->integer('class_id')->unsigned()->index();
$table->integer('student_id')->unsigned()->index();
$table->integer('payment_amount');
$table->timestamps();
$table->softDeletes();
$table->foreign('class_id')->references('id')->on('classes')->onDelete('cascade');
$table->foreign('student_id')->references('id')->on('students')->onDelete('cascade');
缴费表中的缴费金额是指学生可以单独支付每节课的学费。
Payment has many students. And Payment has many Class.
Class has many Payments. And Class has many students.
Student has many Classs. And Student has many payments.
那么如何在没有支付表的数据透视表的情况下定义多对多关系呢?或者我应该为 class_payment_student 表创建数据透视表吗?