diff --git a/app/Http/Controllers/admin/Catalog/Direction/EntranceExaminationController.php b/app/Http/Controllers/admin/Catalog/Direction/EntranceExaminationController.php new file mode 100644 index 0000000..1ed092e --- /dev/null +++ b/app/Http/Controllers/admin/Catalog/Direction/EntranceExaminationController.php @@ -0,0 +1,104 @@ +validated(); + + $entranceExamination = new EntranceExamination(); + $entranceExamination->examination_type_id = $validated['examination_type_id']; + $entranceExamination->direction_id = $validated['direction_id']; + $entranceExamination->subject_id = $validated['subject_id']; + $entranceExamination->scores = $validated['scores']; + $entranceExamination->position = $validated['position']; + $entranceExamination->subject_type_id = $validated['subject_type_id']; + $entranceExamination->save(); + + return redirect()->route('entrance_examinations.index'); + + } + + public function show(EntranceExamination $entranceExamination): View + { + return view( + 'admin.catalog.direction.entrance_examination.show', + compact('entranceExamination') + ); + } + + public function edit(EntranceExamination $entranceExamination): View + { + $directions = Direction::pluck('name', 'id'); + $examination_types = ExaminationType::pluck('name', 'id'); + $subjects = Subject::pluck('name', 'id'); + $subjectTypes = SubjectType::pluck('name', 'id'); + return view( + 'admin.catalog.direction.entrance_examination.edit', + compact( + 'entranceExamination', + 'directions', + 'examination_types', + 'subjects', + 'subjectTypes', + ) + ); + } + + public function update(UpdateEntranceExaminationRequest $request, EntranceExamination $entranceExamination): RedirectResponse + { + $validated = $request->validated(); + + $entranceExamination->examination_type_id = $validated['examination_type_id']; + $entranceExamination->direction_id = $validated['direction_id']; + $entranceExamination->subject_id = $validated['subject_id']; + $entranceExamination->scores = $validated['scores']; + $entranceExamination->position = $validated['position']; + $entranceExamination->subject_type_id = $validated['subject_type_id']; + $entranceExamination->save(); + + return redirect()->route('entrance_examinations.index'); + } + + public function destroy(EntranceExamination $entranceExamination): RedirectResponse + { + $entranceExamination->delete(); + return redirect()->route('entrance_examinations.index'); + } +} diff --git a/app/Http/Requests/admin/Catalog/Direction/StoreEntranceExaminationRequest.php b/app/Http/Requests/admin/Catalog/Direction/StoreEntranceExaminationRequest.php new file mode 100644 index 0000000..f4e535d --- /dev/null +++ b/app/Http/Requests/admin/Catalog/Direction/StoreEntranceExaminationRequest.php @@ -0,0 +1,25 @@ + 'required|numeric|int|max:1000', + 'examination_type_id' => 'required|numeric|int|max:1000', + 'subject_id' => 'required|numeric|int|max:1000', + 'subject_type_id' => 'required|numeric|int|max:1000', + 'scores' => 'required|numeric|int|max:1000', + 'position' => 'required|numeric|int|max:1000', + ]; + } +} diff --git a/app/Models/EntranceExamination.php b/app/Models/EntranceExamination.php new file mode 100644 index 0000000..9ca35cc --- /dev/null +++ b/app/Models/EntranceExamination.php @@ -0,0 +1,42 @@ +belongsTo(ExaminationType::class); + } + + public function direction(): BelongsTo + { + return $this->belongsTo(Direction::class); + } + + public function subject(): BelongsTo + { + return $this->belongsTo(Subject::class); + } + + public function subjectType(): BelongsTo + { + return $this->belongsTo(SubjectType::class); + } +} diff --git a/database/factories/EntranceExaminationFactory.php b/database/factories/EntranceExaminationFactory.php new file mode 100644 index 0000000..2e6c13c --- /dev/null +++ b/database/factories/EntranceExaminationFactory.php @@ -0,0 +1,20 @@ + 1, + 'direction_id' => 1, + 'subject_id' => 1, + 'scores' => 45, + 'position' => fake()->randomDigit(), + 'subject_type_id' => 1, + ]; + } +} diff --git a/database/migrations/2024_02_15_075913_create_entrance_examinations_table.php b/database/migrations/2024_02_15_075913_create_entrance_examinations_table.php new file mode 100644 index 0000000..a18dcf1 --- /dev/null +++ b/database/migrations/2024_02_15_075913_create_entrance_examinations_table.php @@ -0,0 +1,27 @@ +id(); + $table->foreignId('examination_type_id')->constrained('examination_types'); + $table->foreignId('direction_id')->constrained('directions'); + $table->foreignId('subject_id')->constrained('subjects'); + $table->integer('scores'); + $table->integer('position'); + $table->foreignId('subject_type_id')->constrained('subject_types'); + $table->timestamps(); + }); + } + + public function down(): void + { + Schema::dropIfExists('entrance_examinations'); + } +}; diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 6437501..e3e6d62 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -31,6 +31,7 @@ class DatabaseSeeder extends Seeder SubjectSeeder::class, SubjectTypeSeeder::class, DirectionSeeder::class, + EntranceExaminationSeeder::class, ]); $this->call([ diff --git a/database/seeders/EntranceExaminationSeeder.php b/database/seeders/EntranceExaminationSeeder.php new file mode 100644 index 0000000..ec50ae6 --- /dev/null +++ b/database/seeders/EntranceExaminationSeeder.php @@ -0,0 +1,40 @@ +insert([ + [ + 'examination_type_id' => 1, + 'direction_id' => 1, + 'subject_id' => 1, + 'scores' => 40, + 'position' => 1, + 'subject_type_id' => 1, + ], + [ + 'examination_type_id' => 1, + 'direction_id' => 1, + 'subject_id' => 2, + 'scores' => 45, + 'position' => 2, + 'subject_type_id' => 1, + ], + [ + 'examination_type_id' => 1, + 'direction_id' => 1, + 'subject_id' => 3, + 'scores' => 50, + 'position' => 3, + 'subject_type_id' => 1, + ], + ]); + } +} diff --git a/resources/views/admin/catalog/direction/entrance_examination/create.blade.php b/resources/views/admin/catalog/direction/entrance_examination/create.blade.php new file mode 100644 index 0000000..8165235 --- /dev/null +++ b/resources/views/admin/catalog/direction/entrance_examination/create.blade.php @@ -0,0 +1,90 @@ +@extends('layouts.admin_layout') +@section('content') + @auth() +
Направление подготовки | +Тип экзамена | +Предмет | +Тип предмета | +Кол-во баллов | +Позиция | +действия | ++ |
---|---|---|---|---|---|---|---|
{{ $entranceExamination->direction->name }} | +{{ $entranceExamination->examinationType->name }} | +{{ $entranceExamination->subject->name }} | +{{ $entranceExamination->subjectType->name }} | +{{ $entranceExamination->scores }} | +{{ $entranceExamination->position }} | ++ посмотреть + редактировать + удалить + | +
{{ $entranceExamination->direction->name }}
+{{ $entranceExamination->examinationType->name }}
+{{ $entranceExamination->subject->name }}
+{{ $entranceExamination->subjectType->name }}
+{{ $entranceExamination->scores }}
+{{ $entranceExamination->position }}
+