Вы можете создать отношения с этими таблицами. Здесь вам нужны отношения один ко многим.
Вам нужны ученики, уроки, столы
Ученики
Schema::create('students', function (Blueprint $table) {
$table->increments('id');
$table->string('student_name')
});
Уроки
Schema::create('lessons', function (Blueprint $table) {
$table->increments('id');
$table->integer('student_id');
$table->integer('exam_number'); // there will be many exams right ?
$table->integer('lesson1')
$table->integer('lesson2');
$table->integer('lesson-etc');
$table->timestamps();
$table->foreign('student_id')->references('id')->on('students')
});
Затем отредактируйте свои модели, как показано ниже.
Студенческая модель;
public function lessons(){
return $this->hasMany('App\Lesson','student_id','id');
}
и в вашей модели уроков;
public function students(){
return $this->belongsTo('App\Student');
}
Затем в вашем контроллере
$students = Student::whereHas('lessons', function ($query) {
$query->where("exam_number", 2 (or which exam));
})->get();
Наконец, в вашем клинке;
<table >
<tr>
<th>Student Name</th>
<th>Lesson 1</th>
<th>Lesson 2</th>
</tr>
@foreach($students as $student)
<tr>
<td>{{$student->student_name}}</td>
<td>{{$student->lessons->lesson1}}</td>
<td>{{$student->lessons->lesson2}}</td>
</tr>
@endforeach
</table>
Это должно быть работа
person
Community
schedule
04.12.2017