Rebase
This commit is contained in:
parent
bd0aca1ff5
commit
1216f6b81b
@ -5,6 +5,8 @@ namespace App\Http\Controllers;
|
|||||||
use App\Http\Requests\GradeSubjectPostRequest;
|
use App\Http\Requests\GradeSubjectPostRequest;
|
||||||
use App\Models\Grade;
|
use App\Models\Grade;
|
||||||
use App\Models\Subject;
|
use App\Models\Subject;
|
||||||
|
|
||||||
|
use App\Services\JournalService;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
|
|
||||||
@ -25,27 +27,18 @@ class GradeSubjectController extends Controller
|
|||||||
return redirect()->route('grades.show', $grade);
|
return redirect()->route('grades.show', $grade);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function edit(Grade $grade, Subject $subject): View
|
|
||||||
{
|
|
||||||
return view('grade-subject.edit', [
|
|
||||||
'grade' => $grade,
|
|
||||||
'updateSubject' => $subject,
|
|
||||||
'subjects' => Subject::all(),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function update(GradeSubjectPostRequest $request, Grade $grade, Subject $subject): RedirectResponse
|
|
||||||
{
|
|
||||||
$grade->subjects()->detach($subject);
|
|
||||||
$grade->subjects()->attach($request->subject_id);
|
|
||||||
|
|
||||||
return redirect()->route('grades.show', $grade);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function destroy(Grade $grade, Subject $subject): RedirectResponse
|
public function destroy(Grade $grade, Subject $subject): RedirectResponse
|
||||||
{
|
{
|
||||||
$grade->subjects()->detach($subject);
|
$grade->subjects()->detach($subject);
|
||||||
|
|
||||||
return redirect()->route('grades.show', $grade);
|
return redirect()->route('grades.show', $grade);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function journal(Grade $grade, Subject $subject, JournalService $service): View
|
||||||
|
{
|
||||||
|
return view('grade-subject.journal', [
|
||||||
|
'lessons' => $grade->lessons()->where('subject_id', $subject->id)->with('students')->get(),
|
||||||
|
'students' => $grade->students()->orderBy('last_name')->get(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
19
app/Services/JournalService.php
Normal file
19
app/Services/JournalService.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
use App\Models\Grade;
|
||||||
|
use App\Models\Subject;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class JournalService
|
||||||
|
{
|
||||||
|
public function getLessons(Grade $grade, Subject $subject)
|
||||||
|
{
|
||||||
|
return DB::table('lessons')
|
||||||
|
->where('grade_id', $grade->id)
|
||||||
|
->where('subject_id', $subject->id)
|
||||||
|
->orderBy('lesson_date')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
}
|
57
resources/views/grade-subject/journal.blade.php
Normal file
57
resources/views/grade-subject/journal.blade.php
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
@extends('layouts.application')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="container col-md-8">
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
@if (count($students))
|
||||||
|
<div class="card mt-4">
|
||||||
|
<div class="card-header">{{__('Журнал')}}</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">ФИО</th>
|
||||||
|
@foreach ($lessons as $lesson)
|
||||||
|
<th scope="col">{{ $lesson->lesson_date }}</th>
|
||||||
|
@endforeach
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="col"></th>
|
||||||
|
@foreach ($lessons as $lesson)
|
||||||
|
<th scope="col">{{ $lesson->type }}</th>
|
||||||
|
@endforeach
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach ($students as $student)
|
||||||
|
<tr>
|
||||||
|
<td> {{ $student->fio }}</td>
|
||||||
|
@foreach ($lessons as $lesson)
|
||||||
|
<td style="text-align: center; vertical-align: middle;">
|
||||||
|
{{ $student->lessons->find($lesson->id)->pivot->score ?? "-" }}
|
||||||
|
</td>
|
||||||
|
@endforeach
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
{{-- <tr>--}}
|
||||||
|
{{-- <td>Средняя оценка</td>--}}
|
||||||
|
{{-- @foreach ($avgScores as $avgScore)--}}
|
||||||
|
{{-- <td style="text-align: center; vertical-align: middle;">--}}
|
||||||
|
{{-- {{ $avgScore ? $avgScore : "" }}--}}
|
||||||
|
{{-- </td>--}}
|
||||||
|
{{-- @endforeach--}}
|
||||||
|
{{-- </tr>--}}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{-- <div class="mt-4">--}}
|
||||||
|
{{-- @include('journals.list', ['users' => $goods, 'studentName' => 'хорошистов'])--}}
|
||||||
|
{{-- @include('journals.list', ['users' => $perfects, 'studentName' => 'отличников'])--}}
|
||||||
|
{{-- </div>--}}
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
@ -35,7 +35,7 @@
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>
|
<div>
|
||||||
<a href="{{ route('grades.subjects.edit', [$grade, $subject]) }}" class="btn btn-warning">Редактировать</a>
|
<a href="{{ route('grades.subjects.journal', [$grade, $subject]) }}" class="btn btn-primary">Журнал</a>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
@ -44,6 +44,7 @@ Route::middleware('auth')->group(function () {
|
|||||||
Route::middleware([TeacherAction::class])->group(function () {
|
Route::middleware([TeacherAction::class])->group(function () {
|
||||||
Route::get('lessons/{lesson}/scores', [ScoreController::class, 'show'])->name('lessons.scores.show');
|
Route::get('lessons/{lesson}/scores', [ScoreController::class, 'show'])->name('lessons.scores.show');
|
||||||
Route::put('lessons/{lesson}/scores', [ScoreController::class, 'update'])->name('lessons.scores.update');
|
Route::put('lessons/{lesson}/scores', [ScoreController::class, 'update'])->name('lessons.scores.update');
|
||||||
|
Route::get('grades/{grade}/subjects/{subject}/journal', [GradeSubjectController::class, 'journal'])->name('grades.subjects.journal');
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::get('export-pdf', [SubjectController::class, 'exportToPDF'])->name('export-pdf');
|
Route::get('export-pdf', [SubjectController::class, 'exportToPDF'])->name('export-pdf');
|
||||||
|
Loading…
Reference in New Issue
Block a user