From 74d0c8f678bac13e43a27be63c979d794792610f Mon Sep 17 00:00:00 2001 From: aslan Date: Mon, 26 Feb 2024 14:20:16 +0300 Subject: [PATCH] add Period resource --- .../admin/Catalog/DirectionController.php | 19 ++++ app/Models/Direction.php | 5 + .../admin/catalog/direction/show.blade.php | 104 ++++++++++++++++-- routes/admin.php | 2 +- 4 files changed, 117 insertions(+), 13 deletions(-) diff --git a/app/Http/Controllers/admin/Catalog/DirectionController.php b/app/Http/Controllers/admin/Catalog/DirectionController.php index c8c0fd3..969add8 100644 --- a/app/Http/Controllers/admin/Catalog/DirectionController.php +++ b/app/Http/Controllers/admin/Catalog/DirectionController.php @@ -54,6 +54,19 @@ class DirectionController extends Controller $department = $direction->department; $faculty = Faculty::find($department->faculty->id); $educationalInstitution = $faculty->educationalInstitution; + + $ege = $direction->entranceExaminations->where('examination_type_id', '=', '1')->pluck('scores', 'subject_id'); + $spo = $direction->entranceExaminations->where('examination_type_id', '=', '2')->pluck('scores', 'subject_id'); + $magistracy = $direction + ->entranceExaminations + ->where('examination_type_id', '=', '3') + ->pluck('scores', 'subject_id'); + + $budget = $direction->places->where('place_type_id', '=', '1')->pluck('amount', 'education_form_id'); + $paid = $direction->places->where('place_type_id', '=', '2')->pluck('amount', 'education_form_id'); + + $costs = $direction->costs->pluck('cost', 'education_form_id'); + return view( 'admin.catalog.direction.show', compact( @@ -61,6 +74,12 @@ class DirectionController extends Controller 'educationalInstitution', 'faculty', 'department', + 'ege', + 'spo', + 'magistracy', + 'budget', + 'paid', + 'costs', ) ); } diff --git a/app/Models/Direction.php b/app/Models/Direction.php index 6e0abca..082638e 100644 --- a/app/Models/Direction.php +++ b/app/Models/Direction.php @@ -54,4 +54,9 @@ class Direction extends Model { return $this->hasMany('App\Models\DirectionProfile', 'direction_id'); } + + public function periods(): HasMany + { + return $this->hasMany('App\Models\Period', 'direction_id'); + } } diff --git a/resources/views/admin/catalog/direction/show.blade.php b/resources/views/admin/catalog/direction/show.blade.php index cfb1c67..c39ea2b 100644 --- a/resources/views/admin/catalog/direction/show.blade.php +++ b/resources/views/admin/catalog/direction/show.blade.php @@ -1,3 +1,7 @@ +@php + use App\Models\Subject; + use App\Models\EducationForm; +@endphp @extends('layouts.admin_layout') @section('content') @auth() @@ -13,20 +17,96 @@
-

Название

+

Название направления подготовки

{{ $direction->name }}

-

Описание

-

{{ $direction->description }}

-

Позиция

-

{{ $direction->position }}

-

URL

-

{{ $direction->slug }}

-

Кафедра

-

{{ $department->name }}

Уровень Образования

-

{{ $direction->educationLevel->name }}

-

Форма Образования

-

{{ $direction->educationForm->name }}

+

+ {{ $direction->educationLevel->name }} +

+ +

Форма обучения

+

+ {{ $direction->educationForm->name }} +

+ @if(count($ege) !== 0) +

+ Вступительные испытания по ЕГЭ (Минимальное количество баллов) +

+ @foreach($ege as $subject_id => $scores) + @php + $subject = (new Subject())->find($subject_id); + @endphp +

{{ $subject->name }} - {{ $scores }}

+ @endforeach + @endif + @if(count($spo) !== 0) +

+ Профильные вступительные испытания, проводимые в МГТУ для поступающих на базе СПО +

+ @foreach($spo as $subject_id => $scores) + @php + $subject = (new Subject())->find($subject_id); + @endphp +

{{ $subject->name }} - {{ $scores }}

+ @endforeach + @endif + @if(count($magistracy) !== 0) +

+ Вступительные испытания для Магистратуры +

+ @foreach($spo as $subject_id => $scores) + @php + $subject = (new Subject())->find($subject_id); + @endphp +

{{ $subject->name }} - {{ $scores }}

+ @endforeach + @endif + +

+ Количество бюджетных мест +

+ @foreach($budget as $education_form_id => $amount) + @php + $educationForm = (new EducationForm())->find($education_form_id); + @endphp +

{{ $educationForm->name }} - {{ $amount }}

+ @endforeach + +

+ Количество мест по договорам об оказании платных обр. услуг +

+ @foreach($paid as $education_form_id => $amount) + @php + $educationForm = (new EducationForm())->find($education_form_id); + @endphp +

{{ $educationForm->name }} - {{ $amount }}

+ @endforeach + +

+ стоимость обучения +

+ @foreach($costs as $education_form_id => $cost) + @php + $educationForm = (new EducationForm())->find($education_form_id); + @endphp +

{{ $educationForm->name }} - {{ $cost }}

+ @endforeach + +

Профили подготовки

+ @foreach($direction->directionProfiles as $profile) +

{{ $profile->name }}

+ @endforeach + +

Профили подготовки

+ @foreach($direction->periods as $period) + @php + $educationForm = (new EducationForm())->find($period->education_form_id); + @endphp +

{{ $educationForm->name }} - {{ $period->period }}

+ @endforeach + + +
@endauth @endsection diff --git a/routes/admin.php b/routes/admin.php index 88a4e73..ccc9a3d 100644 --- a/routes/admin.php +++ b/routes/admin.php @@ -34,7 +34,7 @@ Route::middleware(['auth', 'verified'])->prefix('admin')->group(function () { Route::resource('/educational_institutions', EducationalInstitutionController::class) ->scoped(['educational_institution' => 'slug']); Route::resource('/directions', DirectionController::class) - ->scoped(['directions' => 'slug']); + ->scoped(['direction' => 'slug']); Route::resource('/departments', DepartmentController::class) ->scoped(['department' => 'slug']);