CourseWork/app/Http/Controllers/ScoreController.php

34 lines
759 B
PHP
Raw Normal View History

2024-05-13 16:44:00 +04:00
<?php
namespace App\Http\Controllers;
2024-05-17 18:46:12 +04:00
use App\Enums\ScoreEnum;
use App\Models\Lesson;
2024-06-16 12:20:48 +04:00
use App\Services\ScoreService;
2024-05-27 16:57:28 +04:00
use Illuminate\Http\Request;
2024-05-13 16:44:00 +04:00
class ScoreController extends Controller
{
2024-05-17 18:46:12 +04:00
public function __construct(
2024-06-16 12:20:48 +04:00
protected ScoreService $service,
2024-05-17 18:46:12 +04:00
){
}
public function show(Lesson $lesson)
{
return view('scores.show', [
2024-06-24 22:04:44 +04:00
'students' => $lesson->students()->orderBy('last_name')->get(),
2024-05-17 18:46:12 +04:00
'lesson' => $lesson,
'scores' => ScoreEnum::cases(),
]);
}
2024-05-27 16:57:28 +04:00
public function update(Request $request, Lesson $lesson)
{
$this->service->update($lesson, $request->toArray());
return redirect()->route('grades.lessons.show', [$lesson->grade, $lesson]);
}
2024-05-13 16:44:00 +04:00
}