fix tests errors

This commit is contained in:
aslan 2024-03-05 16:51:29 +03:00
parent 6ae42fafe8
commit 19ea529eb2
5 changed files with 20 additions and 21 deletions

View File

@ -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']);
}

View File

@ -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');
}
}

View File

@ -1,6 +1,7 @@
<?php
use App\Http\Controllers\admin\PageController;
use App\Models\Faculty;
use Illuminate\Support\Facades\Route;
Route::get('/inostran', function () {
@ -14,7 +15,8 @@ Route::get('/magistr', function () {
Route::get('/home', [PageController::class, 'directions'])->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 () {

View File

@ -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([

View File

@ -36,7 +36,6 @@ class DirectionProfileTest extends TestCase
'position',
'description',
'slug',
'direction_id',
]);
$this->user = User::factory()->create([