63 lines
1.8 KiB
PHP
63 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Http\Requests\GradeTeacherPostRequest;
|
|
use App\Models\Grade;
|
|
use App\Models\Subject;
|
|
use App\Models\Teacher;
|
|
use App\Services\ServiceInterface;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Illuminate\View\View;
|
|
|
|
class GradeTeacherController extends Controller
|
|
{
|
|
public function __construct(
|
|
protected ServiceInterface $service,
|
|
) {
|
|
}
|
|
|
|
public function create(Teacher $teacher, Subject $subject): View
|
|
{
|
|
return view('grade-teacher.create', [
|
|
'teacher' => $teacher,
|
|
'subject' => $subject,
|
|
'grades' => $this->service->getGrades($subject),
|
|
]);
|
|
}
|
|
|
|
public function store(GradeTeacherPostRequest $request, Teacher $teacher, Subject $subject): RedirectResponse
|
|
{
|
|
return redirect()->route('teachers.subjects.show', [
|
|
$this->service->create($request->validated(), $teacher),
|
|
$subject,
|
|
]);
|
|
}
|
|
|
|
public function edit(Teacher $teacher, Subject $subject, Grade $grade): View
|
|
{
|
|
return view('grade-teacher.edit', [
|
|
'teacher' => $teacher,
|
|
'subject' => $subject,
|
|
'updateGrade' => $grade,
|
|
'grades' => $this->service->getGrades($subject),
|
|
]);
|
|
}
|
|
|
|
public function update(GradeTeacherPostRequest $request, Teacher $teacher, Subject $subject, Grade $grade): RedirectResponse
|
|
{
|
|
return redirect()->route('teachers.subjects.show', [
|
|
$this->service->update($teacher, $request->validated(), $grade),
|
|
$subject,
|
|
]);
|
|
}
|
|
|
|
public function destroy(Teacher $teacher, Subject $subject, Grade $grade): RedirectResponse
|
|
{
|
|
return redirect()->route('teachers.subjects.show', [
|
|
$this->service->delete($teacher, $grade),
|
|
$subject,
|
|
]);
|
|
}
|
|
}
|