diff --git a/app/Http/Controllers/GradeController.php b/app/Http/Controllers/GradeController.php index 1aee597..4a60756 100644 --- a/app/Http/Controllers/GradeController.php +++ b/app/Http/Controllers/GradeController.php @@ -11,8 +11,9 @@ use Illuminate\View\View; class GradeController extends Controller { public function __construct( - protected ServiceInterface $gradeService, - ){} + protected ServiceInterface $service, + ) { + } /** * Display a listing of the resource. @@ -20,7 +21,7 @@ class GradeController extends Controller public function index(): View { return view('grades.index', [ - 'grades' => $this->gradeService->getAll(), + 'grades' => $this->service->getAll(), ]); } @@ -37,7 +38,7 @@ class GradeController extends Controller */ public function store(GradePostRequest $request): RedirectResponse { - return redirect()->route('grades.show', $this->gradeService->create($request->validated())); + return redirect()->route('grades.show', $this->service->create($request->validated())); } /** @@ -46,7 +47,8 @@ class GradeController extends Controller public function show(Grade $grade): View { return view('grades.show', [ - 'grade' => $grade, + 'grade' => $grade, + 'subjects' => $grade->subjects, ]); } @@ -65,7 +67,7 @@ class GradeController extends Controller */ public function update(GradePostRequest $request, Grade $grade): RedirectResponse { - return redirect()->route('grades.show', $this->gradeService->update($grade, $request->validated())); + return redirect()->route('grades.show', $this->service->update($grade, $request->validated())); } /** @@ -73,7 +75,7 @@ class GradeController extends Controller */ public function destroy(Grade $grade): RedirectResponse { - $this->gradeService->delete($grade); + $this->service->delete($grade); return redirect()->route('grades.index'); } diff --git a/app/Http/Controllers/GradeSubjectController.php b/app/Http/Controllers/GradeSubjectController.php new file mode 100644 index 0000000..aeaaa0f --- /dev/null +++ b/app/Http/Controllers/GradeSubjectController.php @@ -0,0 +1,51 @@ + $grade, + 'subjects' => $this->service->getAllSubjects(), + ]); + } + + public function store(GradeSubjectPostRequest $request, Grade $grade): RedirectResponse + { + return redirect()->route('grades.show', $this->service->create($request->validated(), $grade)); + } + + public function edit(Grade $grade, Subject $subject): View + { + return view('grade-subject.edit', [ + 'grade' => $grade, + 'updateSubject' => $subject, + 'subjects' => $this->service->getAllSubjects(), + ]); + } + + public function update(GradeSubjectPostRequest $request, Grade $grade, Subject $subject): RedirectResponse + { + return redirect()->route('grades.show', + $this->service->update($grade, $request->validated(), $subject)); + } + + public function destroy(Grade $grade, Subject $subject): RedirectResponse + { + return redirect()->route('grades.show', $this->service->delete($grade, $subject)); + } +} diff --git a/app/Http/Controllers/GradeTeacherController.php b/app/Http/Controllers/GradeTeacherController.php new file mode 100644 index 0000000..735d459 --- /dev/null +++ b/app/Http/Controllers/GradeTeacherController.php @@ -0,0 +1,62 @@ + $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, + ]); + } +} diff --git a/app/Http/Controllers/StudentController.php b/app/Http/Controllers/StudentController.php index db8f8a3..fa76501 100644 --- a/app/Http/Controllers/StudentController.php +++ b/app/Http/Controllers/StudentController.php @@ -12,8 +12,9 @@ use Illuminate\View\View; class StudentController extends Controller { public function __construct( - protected ServiceInterface $studentService - ){} + protected ServiceInterface $service + ) { + } /** * Display a listing of the resource. @@ -21,7 +22,7 @@ class StudentController extends Controller public function index(): View { return view('students.index', [ - 'students' => $this->studentService->getAll(), + 'students' => $this->service->getAll(), ]); } @@ -42,7 +43,7 @@ class StudentController extends Controller { return redirect()->route( 'students.show', - $this->studentService->create($request->validated()) + $this->service->create($request->validated()) ); } @@ -75,7 +76,7 @@ class StudentController extends Controller { return redirect()->route( 'students.show', - $this->studentService->update($student, $request->validated()) + $this->service->update($student, $request->validated()) ); } @@ -84,7 +85,7 @@ class StudentController extends Controller */ public function destroy(Student $student): RedirectResponse { - $this->studentService->delete($student); + $this->service->delete($student); return redirect()->route('students.index'); } diff --git a/app/Http/Controllers/SubjectController.php b/app/Http/Controllers/SubjectController.php index e47975d..58e670f 100644 --- a/app/Http/Controllers/SubjectController.php +++ b/app/Http/Controllers/SubjectController.php @@ -11,8 +11,9 @@ use Illuminate\View\View; class SubjectController extends Controller { public function __construct( - protected ServiceInterface $subjectService, - ){} + protected ServiceInterface $service, + ) { + } /** * Display a listing of the resource. @@ -20,7 +21,7 @@ class SubjectController extends Controller public function index(): View { return view('subjects.index', [ - "subjects" => $this->subjectService->getAll(), + 'subjects' => $this->service->getAll(), ]); } @@ -39,7 +40,7 @@ class SubjectController extends Controller { return redirect()->route( 'subjects.show', - $this->subjectService->create($request->validated()) + $this->service->create($request->validated()) ); } @@ -49,7 +50,7 @@ class SubjectController extends Controller public function show(Subject $subject): View { return view('subjects.show', [ - "subject" => $subject + 'subject' => $subject, ]); } @@ -70,7 +71,7 @@ class SubjectController extends Controller { return redirect()->route( 'subjects.show', - $this->subjectService->update($subject, $request->validated()) + $this->service->update($subject, $request->validated()) ); } @@ -79,7 +80,7 @@ class SubjectController extends Controller */ public function destroy(Subject $subject): RedirectResponse { - $this->subjectService->delete($subject); + $this->service->delete($subject); return redirect()->route('subjects.index'); } diff --git a/app/Http/Controllers/SubjectTeacherController.php b/app/Http/Controllers/SubjectTeacherController.php new file mode 100644 index 0000000..eb8db9a --- /dev/null +++ b/app/Http/Controllers/SubjectTeacherController.php @@ -0,0 +1,60 @@ + $teacher, + 'subjects' => $this->service->getAllSubjects(), + ]); + } + + public function store(SubjectTeacherPostRequest $request, Teacher $teacher): RedirectResponse + { + return redirect()->route('teachers.show', $this->service->create($request->validated(), $teacher)); + } + + public function show(Teacher $teacher, Subject $subject): View + { + return view('subject-teacher.show', [ + 'teacher' => $teacher, + 'subject' => $subject, + 'grades' => $this->service->getGrades($teacher, $subject), + ]); + } + + public function edit(Teacher $teacher, Subject $subject): View + { + return view('subject-teacher.edit', [ + 'teacher' => $teacher, + 'updateSubject' => $subject, + 'subjects' => $this->service->getAllSubjects(), + ]); + } + + public function update(SubjectTeacherPostRequest $request, Teacher $teacher, Subject $subject): RedirectResponse + { + return redirect()->route('teachers.show', + $this->service->update($teacher, $request->validated(), $subject)); + } + + public function destroy(Teacher $teacher, Subject $subject): RedirectResponse + { + return redirect()->route('teachers.show', $this->service->delete($teacher, $subject)); + } +} diff --git a/app/Http/Controllers/TeacherController.php b/app/Http/Controllers/TeacherController.php index d6b5f66..f82ffda 100644 --- a/app/Http/Controllers/TeacherController.php +++ b/app/Http/Controllers/TeacherController.php @@ -11,8 +11,9 @@ use Illuminate\View\View; class TeacherController extends Controller { public function __construct( - protected ServiceInterface $teacherService - ){} + protected ServiceInterface $service + ) { + } /** * Display a listing of the resource. @@ -20,7 +21,7 @@ class TeacherController extends Controller public function index(): View { return view('teachers.index', [ - 'teachers' => $this->teacherService->getAll(), + 'teachers' => $this->service->getAll(), ]); } @@ -39,7 +40,7 @@ class TeacherController extends Controller { return redirect()->route( 'teachers.show', - $this->teacherService->create($request->validated()) + $this->service->create($request->validated()) ); } @@ -50,6 +51,7 @@ class TeacherController extends Controller { return view('teachers.show', [ 'teacher' => $teacher, + 'subjects' => $teacher->subjects, ]); } @@ -70,7 +72,7 @@ class TeacherController extends Controller { return redirect()->route( 'teachers.show', - $this->teacherService->update($teacher, $request->validated()) + $this->service->update($teacher, $request->validated()) ); } @@ -79,7 +81,7 @@ class TeacherController extends Controller */ public function destroy(Teacher $teacher): RedirectResponse { - $this->teacherService->delete($teacher); + $this->service->delete($teacher); return redirect()->route('teachers.index'); } diff --git a/app/Http/Requests/GradeSubjectPostRequest.php b/app/Http/Requests/GradeSubjectPostRequest.php new file mode 100644 index 0000000..4fe34da --- /dev/null +++ b/app/Http/Requests/GradeSubjectPostRequest.php @@ -0,0 +1,28 @@ +|string> + */ + public function rules(): array + { + return [ + 'subject_id' => 'required|exists:subjects,id', + ]; + } +} diff --git a/app/Http/Requests/GradeTeacherPostRequest.php b/app/Http/Requests/GradeTeacherPostRequest.php new file mode 100644 index 0000000..86502e4 --- /dev/null +++ b/app/Http/Requests/GradeTeacherPostRequest.php @@ -0,0 +1,28 @@ +|string> + */ + public function rules(): array + { + return [ + 'grade_id' => 'required|exists:grades,id', + ]; + } +} diff --git a/app/Http/Requests/StudentPostRequest.php b/app/Http/Requests/StudentPostRequest.php index 71bc504..132c34d 100644 --- a/app/Http/Requests/StudentPostRequest.php +++ b/app/Http/Requests/StudentPostRequest.php @@ -2,8 +2,6 @@ namespace App\Http\Requests; -use App\Enums\RoleEnum; -use Illuminate\Contracts\Validation\ValidationRule; use Illuminate\Foundation\Http\FormRequest; class StudentPostRequest extends FormRequest diff --git a/app/Http/Requests/SubjectPostRequest.php b/app/Http/Requests/SubjectPostRequest.php index 6a97968..6166d9d 100644 --- a/app/Http/Requests/SubjectPostRequest.php +++ b/app/Http/Requests/SubjectPostRequest.php @@ -22,7 +22,7 @@ class SubjectPostRequest extends FormRequest public function rules(): array { return [ - 'name' => 'required|unique:grades|max:255', + 'name' => 'required|unique:subjects|max:255', ]; } } diff --git a/app/Http/Requests/SubjectTeacherPostRequest.php b/app/Http/Requests/SubjectTeacherPostRequest.php new file mode 100644 index 0000000..68e09c8 --- /dev/null +++ b/app/Http/Requests/SubjectTeacherPostRequest.php @@ -0,0 +1,28 @@ +|string> + */ + public function rules(): array + { + return [ + 'subject_id' => 'required|exists:subjects,id', + ]; + } +} diff --git a/app/Http/Requests/TeacherPostRequest.php b/app/Http/Requests/TeacherPostRequest.php index 932d7d5..e3aea8a 100644 --- a/app/Http/Requests/TeacherPostRequest.php +++ b/app/Http/Requests/TeacherPostRequest.php @@ -2,8 +2,6 @@ namespace App\Http\Requests; -use App\Enums\RoleEnum; -use Illuminate\Contracts\Validation\ValidationRule; use Illuminate\Foundation\Http\FormRequest; class TeacherPostRequest extends FormRequest diff --git a/app/Models/Student.php b/app/Models/Student.php index 7e97ab8..43844ae 100644 --- a/app/Models/Student.php +++ b/app/Models/Student.php @@ -2,12 +2,13 @@ namespace App\Models; +use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\MorphOne; -use Illuminate\Database\Eloquent\Builder; + class Student extends Model { use HasFactory; @@ -33,7 +34,7 @@ class Student extends Model public function scopeFilter(Builder $query): void { $name = request('name'); - $query->when($name, function (Builder $query, $name){ + $query->when($name, function (Builder $query, $name) { $query->whereRaw('CONCAT (name, \' \', surname, \' \', patronymic) ilike ?', ["$name%"]); $query->orWhereRaw('CONCAT (name, \' \', patronymic, \' \', surname) ilike ?', ["$name%"]); $query->orWhereRaw('CONCAT (surname, \' \', name, \' \', patronymic) ilike ?', ["$name%"]); @@ -46,7 +47,7 @@ class Student extends Model public function fio(): Attribute { return Attribute::make( - get: fn () => $this->last_name . " " . $this->name . " " . $this->middle_name, + get: fn () => $this->last_name.' '.$this->name.' '.$this->middle_name, ); } } diff --git a/app/Models/Teacher.php b/app/Models/Teacher.php index c5cbf24..f18c015 100644 --- a/app/Models/Teacher.php +++ b/app/Models/Teacher.php @@ -2,12 +2,13 @@ namespace App\Models; +use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\MorphOne; -use Illuminate\Database\Eloquent\Builder; + class Teacher extends Model { use HasFactory; @@ -37,7 +38,7 @@ class Teacher extends Model public function scopeFilter(Builder $query): void { $name = request('name'); - $query->when($name, function (Builder $query, $name){ + $query->when($name, function (Builder $query, $name) { $query->whereRaw('CONCAT (name, \' \', surname, \' \', patronymic) ilike ?', ["$name%"]); $query->orWhereRaw('CONCAT (name, \' \', patronymic, \' \', surname) ilike ?', ["$name%"]); $query->orWhereRaw('CONCAT (surname, \' \', name, \' \', patronymic) ilike ?', ["$name%"]); @@ -50,7 +51,7 @@ class Teacher extends Model public function fio(): Attribute { return Attribute::make( - get: fn () => $this->last_name . " " . $this->name . " " . $this->middle_name, + get: fn () => $this->last_name.' '.$this->name.' '.$this->middle_name, ); } } diff --git a/app/Providers/ModelServiceProvider.php b/app/Providers/ModelServiceProvider.php index cfbd547..e7971b8 100644 --- a/app/Providers/ModelServiceProvider.php +++ b/app/Providers/ModelServiceProvider.php @@ -3,13 +3,19 @@ namespace App\Providers; use App\Http\Controllers\GradeController; +use App\Http\Controllers\GradeSubjectController; +use App\Http\Controllers\GradeTeacherController; use App\Http\Controllers\StudentController; use App\Http\Controllers\SubjectController; +use App\Http\Controllers\SubjectTeacherController; use App\Http\Controllers\TeacherController; use App\Services\GradeService; +use App\Services\GradeSubjectService; +use App\Services\GradeTeacherService; use App\Services\ServiceInterface; use App\Services\StudentService; use App\Services\SubjectService; +use App\Services\SubjectTeacherService; use App\Services\TeacherService; use Illuminate\Support\ServiceProvider; @@ -43,6 +49,24 @@ class ModelServiceProvider extends ServiceProvider ->give(function () { return new SubjectService(); }); + + $this->app->when(SubjectTeacherController::class) + ->needs(ServiceInterface::class) + ->give(function () { + return new SubjectTeacherService(); + }); + + $this->app->when(GradeSubjectController::class) + ->needs(ServiceInterface::class) + ->give(function () { + return new GradeSubjectService(); + }); + + $this->app->when(GradeTeacherController::class) + ->needs(ServiceInterface::class) + ->give(function () { + return new GradeTeacherService(); + }); } /** diff --git a/app/Services/GradeService.php b/app/Services/GradeService.php index b59e22f..6ab6453 100644 --- a/app/Services/GradeService.php +++ b/app/Services/GradeService.php @@ -3,14 +3,14 @@ namespace App\Services; use App\Models\Grade; +use Illuminate\Database\Eloquent\Model; use Illuminate\Pagination\LengthAwarePaginator; class GradeService implements ServiceInterface { - public function getAll(): LengthAwarePaginator { - return Grade::filter()->paginate(10)->withQueryString(); + return Grade::filter()->paginate(5)->withQueryString(); } public function create(array $data): Grade @@ -18,7 +18,7 @@ class GradeService implements ServiceInterface return Grade::create($data); } - public function update($model, array $data): Grade + public function update(Model $model, array $data): Grade { $model->update($data); diff --git a/app/Services/GradeSubjectService.php b/app/Services/GradeSubjectService.php new file mode 100644 index 0000000..55d4793 --- /dev/null +++ b/app/Services/GradeSubjectService.php @@ -0,0 +1,43 @@ +subjects; + } + + public function getAllSubjects(): Collection + { + return Subject::all(); + } + + public function create(array $data, ?Model $model = null): Grade + { + $model->subjects()->syncWithoutDetaching($data['subject_id']); + + return $model; + } + + public function update(Model $model, array $data, ?Model $subject = null): Grade + { + $model->subjects()->detach($subject->id); + $model->subjects()->attach($data['subject_id']); + + return $model; + } + + public function delete(Model $model, ?Model $subject = null): Grade + { + $model->subjects()->detach($subject); + + return $model; + } +} diff --git a/app/Services/GradeTeacherService.php b/app/Services/GradeTeacherService.php new file mode 100644 index 0000000..4ed24bc --- /dev/null +++ b/app/Services/GradeTeacherService.php @@ -0,0 +1,47 @@ +grades() + ->join('grade_subject', 'grades.id', '=', 'grade_subject.grade_id') + ->where('subject_id', $subject->id) + ->get(); + } + + public function getGrades(Subject $subject): Collection + { + return $subject->grades; + } + + public function create(array $data, ?Model $model = null): Teacher + { + $model->grades()->syncWithoutDetaching($data['grade_id']); + + return $model; + } + + public function update(Model $model, array $data, ?Model $grade = null): Teacher + { + $model->grades()->detach($grade->id); + $model->grades()->attach($data['grade_id']); + + return $model; + } + + public function delete(Model $model, ?Model $grade = null): Teacher + { + $model->grades()->detach($grade); + + return $model; + } +} diff --git a/app/Services/ServiceInterface.php b/app/Services/ServiceInterface.php index bcc6856..ef9a45c 100644 --- a/app/Services/ServiceInterface.php +++ b/app/Services/ServiceInterface.php @@ -2,13 +2,15 @@ namespace App\Services; +use Illuminate\Database\Eloquent\Model; + interface ServiceInterface { public function getAll(); - public function create(array $data); + public function create(array $data): Model; - public function update($model, array $data); + public function update(Model $model, array $data): Model; - public function delete($model); + public function delete(Model $model); } diff --git a/app/Services/StudentService.php b/app/Services/StudentService.php index ea92863..6aafb74 100644 --- a/app/Services/StudentService.php +++ b/app/Services/StudentService.php @@ -3,7 +3,6 @@ namespace App\Services; use App\Models\Student; -use App\Models\Teacher; use App\Models\User; use Illuminate\Pagination\LengthAwarePaginator; @@ -11,7 +10,7 @@ class StudentService implements ServiceInterface { public function getAll(): LengthAwarePaginator { - return Student::filter()->paginate(10)->withQueryString(); + return Student::filter()->paginate(5)->withQueryString(); } public function create(array $data): Student diff --git a/app/Services/SubjectService.php b/app/Services/SubjectService.php index 2d22384..6687465 100644 --- a/app/Services/SubjectService.php +++ b/app/Services/SubjectService.php @@ -3,14 +3,14 @@ namespace App\Services; use App\Models\Subject; +use Illuminate\Database\Eloquent\Model; use Illuminate\Pagination\LengthAwarePaginator; class SubjectService implements ServiceInterface { - public function getAll(): LengthAwarePaginator { - return Subject::filter()->paginate(10)->withQueryString(); + return Subject::filter()->paginate(5)->withQueryString(); } public function create(array $data): Subject @@ -18,14 +18,14 @@ class SubjectService implements ServiceInterface return Subject::create($data); } - public function update($model, array $data): Subject + public function update(Model $model, array $data): Subject { $model->update($data); return $model; } - public function delete($model): void + public function delete(Model $model): void { $model->delete(); } diff --git a/app/Services/SubjectTeacherService.php b/app/Services/SubjectTeacherService.php new file mode 100644 index 0000000..8e22055 --- /dev/null +++ b/app/Services/SubjectTeacherService.php @@ -0,0 +1,51 @@ +subjects; + } + + public function getAllSubjects(): Collection + { + return Subject::all(); + } + + public function getGrades(Teacher $teacher, Subject $subject): Collection + { + return $teacher + ->grades() + ->join('grade_subject', 'grades.id', '=', 'grade_subject.grade_id') + ->where('subject_id', $subject->id)->get(); + } + + public function create(array $data, ?Model $model = null): Teacher + { + $model->subjects()->syncWithoutDetaching($data['subject_id']); + + return $model; + } + + public function update(Model $model, array $data, ?Model $subject = null): Teacher + { + $model->subjects()->detach($subject->id); + $model->subjects()->attach($data['subject_id']); + + return $model; + } + + public function delete(Model $model, ?Model $subject = null): Teacher + { + $model->subjects()->detach($subject); + + return $model; + } +} diff --git a/app/Services/TeacherService.php b/app/Services/TeacherService.php index 46573d1..ea04740 100644 --- a/app/Services/TeacherService.php +++ b/app/Services/TeacherService.php @@ -2,7 +2,6 @@ namespace App\Services; -use App\Models\Student; use App\Models\Teacher; use App\Models\User; use Illuminate\Pagination\LengthAwarePaginator; @@ -11,7 +10,7 @@ class TeacherService implements ServiceInterface { public function getAll(): LengthAwarePaginator { - return Teacher::filter()->paginate(2)->withQueryString(); + return Teacher::filter()->paginate(5)->withQueryString(); } public function create(array $data): Teacher diff --git a/resources/views/grade-subject/create.blade.php b/resources/views/grade-subject/create.blade.php new file mode 100644 index 0000000..7777bc5 --- /dev/null +++ b/resources/views/grade-subject/create.blade.php @@ -0,0 +1,5 @@ +@extends('layouts.app') + +@section('content') + @include('grade-subject.form', ['route' => route('grades.subjects.store', $grade), 'method' => 'POST']) +@endsection diff --git a/resources/views/grade-subject/edit.blade.php b/resources/views/grade-subject/edit.blade.php new file mode 100644 index 0000000..2c4c73c --- /dev/null +++ b/resources/views/grade-subject/edit.blade.php @@ -0,0 +1,8 @@ +@extends('layouts.app') + +@section('content') + @include('grade-subject.form', [ + 'route' => route('grades.subjects.update', + ['grade' => $grade, 'subject' => $updateSubject] + ), 'method' => 'PUT']) +@endsection diff --git a/resources/views/grade-subject/form.blade.php b/resources/views/grade-subject/form.blade.php new file mode 100644 index 0000000..819fa69 --- /dev/null +++ b/resources/views/grade-subject/form.blade.php @@ -0,0 +1,24 @@ +
+
+
+
+
+ @csrf + @method($method) +
+ + +
+ +
+
+
+
+
diff --git a/resources/views/grade-teacher/create.blade.php b/resources/views/grade-teacher/create.blade.php new file mode 100644 index 0000000..45e235c --- /dev/null +++ b/resources/views/grade-teacher/create.blade.php @@ -0,0 +1,5 @@ +@extends('layouts.app') + +@section('content') + @include('grade-teacher.form', ['route' => route('teachers.subjects.grades.store', [$teacher, $subject]), 'method' => 'POST']) +@endsection diff --git a/resources/views/grade-teacher/edit.blade.php b/resources/views/grade-teacher/edit.blade.php new file mode 100644 index 0000000..0a038f6 --- /dev/null +++ b/resources/views/grade-teacher/edit.blade.php @@ -0,0 +1,8 @@ +@extends('layouts.app') + +@section('content') + @include('grade-teacher.form', [ + 'route' => route('teachers.subjects.grades.update', + ['teacher' => $teacher, 'subject' => $subject, 'grade' => $updateGrade] + ), 'method' => 'PUT']) +@endsection diff --git a/resources/views/grade-teacher/form.blade.php b/resources/views/grade-teacher/form.blade.php new file mode 100644 index 0000000..7372494 --- /dev/null +++ b/resources/views/grade-teacher/form.blade.php @@ -0,0 +1,27 @@ +
+
+
+
+ {{ $subject->name }} +
+
+
+ @csrf + @method($method) +
+ + +
+ +
+
+
+
+
diff --git a/resources/views/grades/index.blade.php b/resources/views/grades/index.blade.php index ddff5cc..a2dffb7 100644 --- a/resources/views/grades/index.blade.php +++ b/resources/views/grades/index.blade.php @@ -3,12 +3,6 @@ @section('content')
-
-
{{__('Новый класс')}}
- -
{{__('Поиск класса')}}
@@ -24,10 +18,10 @@
- @if (count($grades))
{{__('Классы')}}
+ @if (count($grades)) @@ -64,10 +58,15 @@ @endforeach
Название
+ @else +

Классы отсутствуют

+ @endif +
+
- @endif
@endsection diff --git a/resources/views/grades/show.blade.php b/resources/views/grades/show.blade.php index cfa51d7..0370dbe 100644 --- a/resources/views/grades/show.blade.php +++ b/resources/views/grades/show.blade.php @@ -14,6 +14,49 @@ Редактировать +
+
+ {{__('Журнал предметов')}} +
+
+ @if(count($subjects)) + + + + + + + @foreach ($subjects as $subject) + + + + + + @endforeach + +
Название 
+
+ {{ $subject->name }} +
+
+ + +
+ @csrf + @method('DELETE') + +
+
+ @else +

У класса отсутствуют предметы

+ @endif +
+ +
@endsection diff --git a/resources/views/students/edit.blade.php b/resources/views/students/edit.blade.php index eb50242..2dfa1ba 100644 --- a/resources/views/students/edit.blade.php +++ b/resources/views/students/edit.blade.php @@ -1,5 +1,5 @@ @extends('layouts.app') @section('content') - @include('students.form', ['route' => route('students.update', $user), 'method' => 'PUT']) + @include('students.form', ['route' => route('students.update', $student), 'method' => 'PUT']) @endsection diff --git a/resources/views/students/form.blade.php b/resources/views/students/form.blade.php index 82f694c..69471b5 100644 --- a/resources/views/students/form.blade.php +++ b/resources/views/students/form.blade.php @@ -34,11 +34,11 @@
- +
- +
diff --git a/resources/views/students/index.blade.php b/resources/views/students/index.blade.php index e1ec961..822b81a 100644 --- a/resources/views/students/index.blade.php +++ b/resources/views/students/index.blade.php @@ -3,12 +3,6 @@ @section('content')
-
-
{{__('Новый ученик')}}
- -
{{__('Поиск ученика')}}
@@ -23,43 +17,48 @@
- @if (count($students)) -
-
{{__('Ученики')}}
-
- - - - - - - @foreach ($students as $student) - - - - - - @endforeach - -
ФИО 
- - - - -
- @csrf - @method('DELETE') - -
-
-
- +
+
{{__('Ученики')}}
+
+ @if(count($students)) + + + + + + + @foreach ($students as $student) + + + + + + @endforeach + +
ФИО 
+ + + + +
+ @csrf + @method('DELETE') + +
+
+ @else +

Ученики остутствуют

+ @endif
- @endif + + +
@endsection diff --git a/resources/views/subject-teacher/create.blade.php b/resources/views/subject-teacher/create.blade.php new file mode 100644 index 0000000..b91d9d4 --- /dev/null +++ b/resources/views/subject-teacher/create.blade.php @@ -0,0 +1,5 @@ +@extends('layouts.app') + +@section('content') + @include('subject-teacher.form', ['route' => route('teachers.subjects.store', $teacher), 'method' => 'POST']) +@endsection diff --git a/resources/views/subject-teacher/edit.blade.php b/resources/views/subject-teacher/edit.blade.php new file mode 100644 index 0000000..b124ec1 --- /dev/null +++ b/resources/views/subject-teacher/edit.blade.php @@ -0,0 +1,8 @@ +@extends('layouts.app') + +@section('content') + @include('subject-teacher.form', [ + 'route' => route('teachers.subjects.update', + ['teacher' => $teacher, 'subject' => $updateSubject] + ), 'method' => 'PUT']) +@endsection diff --git a/resources/views/subject-teacher/form.blade.php b/resources/views/subject-teacher/form.blade.php new file mode 100644 index 0000000..819fa69 --- /dev/null +++ b/resources/views/subject-teacher/form.blade.php @@ -0,0 +1,24 @@ +
+
+
+
+
+ @csrf + @method($method) +
+ + +
+ +
+
+
+
+
diff --git a/resources/views/subject-teacher/show.blade.php b/resources/views/subject-teacher/show.blade.php new file mode 100644 index 0000000..3438b82 --- /dev/null +++ b/resources/views/subject-teacher/show.blade.php @@ -0,0 +1,52 @@ +@extends('layouts.app') + +@section('content') +
+
+
+
+ {{ $subject->name }} +
+
+ @if(count($grades)) + + + + + + + @foreach ($grades as $grade) + + + + + + @endforeach + +
Название 
+
+ {{ $grade->name }} +
+
+ + +
+ @csrf + @method('DELETE') + +
+
+ @else +

У учителя отсутствуют классы

+ @endif +
+ +
+
+
+@endsection + diff --git a/resources/views/subjects/index.blade.php b/resources/views/subjects/index.blade.php index 53df0be..9e45ef4 100644 --- a/resources/views/subjects/index.blade.php +++ b/resources/views/subjects/index.blade.php @@ -3,12 +3,6 @@ @section('content')
-
-
{{__('Новый предмет')}}
- -
{{__('Поиск предмета')}}
@@ -23,43 +17,48 @@
- @if (count($subjects)) -
-
{{__('Предметы')}}
-
- - - - - - - @foreach ($subjects as $subject) - - - - - - @endforeach - -
Название 
- - - - -
- @csrf - @method('DELETE') - -
-
-
- +
+
{{__('Предметы')}}
+
+ @if (count($subjects)) + + + + + + + @foreach ($subjects as $subject) + + + + + + @endforeach + +
Название 
+ + + + +
+ @csrf + @method('DELETE') + +
+
+ @else +

Предметы отсутствуют

+ @endif
- @endif + + +
@endsection diff --git a/resources/views/teachers/edit.blade.php b/resources/views/teachers/edit.blade.php index 7b8428a..bfaced9 100644 --- a/resources/views/teachers/edit.blade.php +++ b/resources/views/teachers/edit.blade.php @@ -1,5 +1,5 @@ @extends('layouts.app') @section('content') - @include('teachers.form', ['route' => route('teachers.update', $user), 'method' => 'PUT']) + @include('teachers.form', ['route' => route('teachers.update', $teacher), 'method' => 'PUT']) @endsection diff --git a/resources/views/teachers/form.blade.php b/resources/views/teachers/form.blade.php index 8f27def..f74896c 100644 --- a/resources/views/teachers/form.blade.php +++ b/resources/views/teachers/form.blade.php @@ -23,11 +23,11 @@
- +
- +
diff --git a/resources/views/teachers/index.blade.php b/resources/views/teachers/index.blade.php index 3c3f89c..4aeaae7 100644 --- a/resources/views/teachers/index.blade.php +++ b/resources/views/teachers/index.blade.php @@ -3,12 +3,6 @@ @section('content')
-
-
{{__('Новый учитель')}}
- -
{{__('Поиск учителя')}}
@@ -23,10 +17,10 @@
- @if (count($teachers))
{{__('Учителя')}}
+ @if (count($teachers)) @@ -56,10 +50,15 @@ @endforeach
ФИО
+ @else +

Учителя отсутствуют

+ @endif +
+
- @endif
@endsection diff --git a/resources/views/teachers/show.blade.php b/resources/views/teachers/show.blade.php index d3d7b9d..0286934 100644 --- a/resources/views/teachers/show.blade.php +++ b/resources/views/teachers/show.blade.php @@ -4,7 +4,9 @@
-
{{ ('Учитель') }}
+
+ {{ ('Учитель') }} +
ФИО: {{ $teacher->fio }}
@@ -17,6 +19,49 @@ Редактировать
+
+
+ {{__('Предметы учителя')}} +
+
+ @if(count($subjects)) + + + + + + + @foreach ($subjects as $subject) + + + + + + @endforeach + +
Название 
+ + + + +
+ @csrf + @method('DELETE') + +
+
+ @else +

У учителя отсутствуют предметы

+ @endif +
+ +
@endsection diff --git a/routes/web.php b/routes/web.php index 6758792..59933d2 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,8 +1,11 @@ route('grades.index'); }); -Route::resource('grades', GradeController::class); -Route::resource('subjects', SubjectController::class); -Route::resource('students', StudentController::class); -Route::resource('teachers', TeacherController::class); +Route::resources([ + 'grades' => GradeController::class, + 'subjects' => SubjectController::class, + 'students' => StudentController::class, + 'teachers' => TeacherController::class, +]); + +Route::resource('teachers.subjects', SubjectTeacherController::class)->except('index'); +Route::resource('teachers.subjects.grades', GradeTeacherController::class)->except('index', 'show'); +Route::resource('grades.subjects', GradeSubjectController::class)->except('index', 'show');