Hi all,
I am trying to build an app for university students.
My idea is to retrieve data from the database, where for each student should be displayed courses depending on which semester the student is. In other words if student A is in second semester and let's say the course Databases is being held only in second semester, for student A I should have on the page only Databases as eligible course.
I have the following tables:
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
public function up()
{
Schema::create('semesters', function (Blueprint $table) {
$table->increments('id');
$table->integer('number');
$table->timestamps();
});
}
public function up()
{
Schema::create('additional_info_students', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id')->unsigned();
$table->foreign('user_id')->references('id')->on('users');
$table->string('first_name', 255);
$table->string('last_name', 255);
$table->integer('faculty_number')->unique();
$table->integer('group_number');
$table->integer('year');
$table->integer('semester_id')->unsigned();
$table->foreign('semester_id')->references('id')->on('semesters');
$table->timestamps();
});
}
public function up()
{
Schema::create('courses', function (Blueprint $table) {
$table->increments('id');
$table->string('name', 255);
$table->string('language', 10);
$table->longText('description', 30000000);
$table->integer('semester_id')->unsigned();
$table->foreign('semester_id')->references('id')->on('semesters');
$table->timestamps();
});
}
public function up()
{
Schema::create('courses_assign_students', function (Blueprint $table) {
$table->increments('id');
$table->integer('student_id')->unsigned();
$table->foreign('student_id')->references('user_id')->on('additional_info_students');
$table->integer('courses_id')->unsigned();
$table->foreign('courses_id')->references('id')->on('courses');
$table->timestamps();
});
}
Would this work? I can not seem to join them correctly in order to get what I need.
Thanks in advance :)