How to define relationship between below tables.
Class->belongsToMany('Student');
Student->belongsToMany('Class');
Class table and Student table pivoted by class_student table
I have Payment table as below
$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 amount in the payment table means students can pay for each class tuition fee separately.
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.
So how can I define many to many relationship without pivot table for Payment table? Or Should I create pivot table for class_payment_student table?