diff --git a/app/Http/Controllers/admin/Catalog/DirectionController.php b/app/Http/Controllers/admin/Catalog/DirectionController.php index ab73dea..2fb24b4 100644 --- a/app/Http/Controllers/admin/Catalog/DirectionController.php +++ b/app/Http/Controllers/admin/Catalog/DirectionController.php @@ -73,18 +73,21 @@ class DirectionController extends Controller $direction->period = $validated['period']; $direction->save(); - foreach ($validated['entrance-examination'] as $data) { - $entranceExamination = new EntranceExamination(); - $entranceExamination->examination_type_id = $data['examination_type_id']; - $entranceExamination->direction_id = $direction->id; - $entranceExamination->subject_id = $data['subject_id']; - $entranceExamination->scores = $data['scores']; - $entranceExamination->position = $data['position']; - $entranceExamination->subject_type_id = $data['subject_type_id']; - $entranceExamination->save(); + if (array_key_exists('entrance-examination', $validated)) { + foreach ($validated['entrance-examination'] as $data) { + $entranceExamination = new EntranceExamination(); + $entranceExamination->examination_type_id = $data['examination_type_id']; + $entranceExamination->direction_id = $direction->id; + $entranceExamination->subject_id = $data['subject_id']; + $entranceExamination->scores = $data['scores']; + $entranceExamination->position = $data['position']; + $entranceExamination->subject_type_id = $data['subject_type_id']; + $entranceExamination->save(); + } } + if (array_key_exists('direction_profiles', $validated)) { $direction->directionProfiles()->attach($validated['direction_profiles']); } diff --git a/app/Models/EducationForm.php b/app/Models/EducationForm.php index d243076..94bb1f6 100644 --- a/app/Models/EducationForm.php +++ b/app/Models/EducationForm.php @@ -21,14 +21,4 @@ class EducationForm extends Model { return $this->hasMany('App\Models\Direction', 'education_form_id'); } - - public function places(): HasMany - { - return $this->hasMany('App\Models\Place', 'education_form_id'); - } - - public function costs(): HasMany - { - return $this->hasMany('App\Models\Cost', 'education_form_id'); - } } diff --git a/routes/pages.php b/routes/pages.php index 2301db9..4e8d60d 100644 --- a/routes/pages.php +++ b/routes/pages.php @@ -1,6 +1,7 @@ name('home'); Route::get('/', function () { - return view('new-design.bakalavr-special'); + $faculties = Faculty::all(); + return view('new-design.bakalavr-special', compact('faculties')); })->name('bakalavr-special'); Route::get('/course', function () { diff --git a/tests/Feature/admin/catalog/DirectionTest.php b/tests/Feature/admin/catalog/DirectionTest.php index 7625bc8..7000ac2 100644 --- a/tests/Feature/admin/catalog/DirectionTest.php +++ b/tests/Feature/admin/catalog/DirectionTest.php @@ -47,6 +47,11 @@ class DirectionTest extends TestCase 'education_level_id', 'education_form_id', 'department_id', + 'budget_places', + 'quota', + 'paid_places', + 'cost_paid_place', + 'period' ]); $this->user = User::factory()->create([ diff --git a/tests/Feature/admin/catalog/direction/DirectionProfileTest.php b/tests/Feature/admin/catalog/direction/DirectionProfileTest.php index b67ce14..7c47ef6 100644 --- a/tests/Feature/admin/catalog/direction/DirectionProfileTest.php +++ b/tests/Feature/admin/catalog/direction/DirectionProfileTest.php @@ -36,7 +36,6 @@ class DirectionProfileTest extends TestCase 'position', 'description', 'slug', - 'direction_id', ]); $this->user = User::factory()->create([