У меня есть две таблицы. Один из них - student_attendances, а другой - студенты. Теперь я хочу установить внешний ключ между этими двумя таблицами. А также у меня есть строковый тип данных, для которого я хочу установить внешний ключ, но он дает мне ошибку. Ниже мой код. Сделайте обзор этого ...
// Таблица Students_attendances
public function up()
{
Schema::create('students_attendances', function (Blueprint $table) {
$table->increments('id');
$table->integer('class_id')->index()->unsigned()->nullable();
$table->string('student_id');
$table->string('first_name');
$table->string('last_name');
$table->string('attendance');
$table->timestamps();
$table->foreign('student_id')->references('student_id')->on('students')->onDelete('cascade');
});
}
// стол для студентов
public function up()
{
Schema::create('students', function (Blueprint $table) {
$table->increments('id');
$table->string('student_id');
$table->string('first_name');
$table->string('last_name');
$table->string('DOB');
$table->integer('students_class_id')->index()->unsigned()->nullable();
$table->string('gender');
$table->string('blood_group');
$table->string('religion');
$table->string('photo_id');
$table->string('student_address');
$table->integer('student_phone_no');
$table->string('guardian_name');
$table->string('guardian_gender');
$table->string('guardian_relation');
$table->string('guardian_occupation');
$table->integer('guardian_phone_no');
$table->string('email')->unique();
$table->string('NIC_no');
$table->string('guardian_address');
// $table->string('document_id');
$table->string('username');
$table->string('password');
$table->timestamps();
});
}