From 8e8b16d5400691cd088683a26329a2a5bff7ee67 Mon Sep 17 00:00:00 2001 From: ROMANGOLIENKO Date: Fri, 15 Mar 2024 16:09:19 +0300 Subject: [PATCH] adding logic to direction view --- .../Controllers/Api/CalculatorController.php | 2 +- app/Services/DirectonHtmlBuilder.php | 85 +++++++++++++++++-- .../new-design/bakalavr-special.blade.php | 32 +++++-- 3 files changed, 108 insertions(+), 11 deletions(-) diff --git a/app/Http/Controllers/Api/CalculatorController.php b/app/Http/Controllers/Api/CalculatorController.php index dd7a058..f66ac75 100644 --- a/app/Http/Controllers/Api/CalculatorController.php +++ b/app/Http/Controllers/Api/CalculatorController.php @@ -53,7 +53,7 @@ class CalculatorController extends Controller
{$direction->code}
-
{$direction->name}
+
{$direction->name}

{$direction->description}

diff --git a/app/Services/DirectonHtmlBuilder.php b/app/Services/DirectonHtmlBuilder.php index 89b34f4..82cc2ae 100644 --- a/app/Services/DirectonHtmlBuilder.php +++ b/app/Services/DirectonHtmlBuilder.php @@ -9,17 +9,87 @@ use PhpParser\Node\Expr\Array_; class DirectonHtmlBuilder { private array $direction; + + public function __construct($direction) { $this->direction = $direction; + } public function getHTML() { $direction = $this->direction; + + + $fon_3 = URL::to('img/front-page/bakalavr-special/fon3_blok.png'); - $educationForm = implode(", ", $direction['educationForm']); + + + + + $educationForms = ''; + foreach ($direction['educationForms'] as $key => $educationForm) { + $educationForms .= $key . ', '; + } + $educationForms = substr($educationForms, 0, -2); + + + + + + $budget_places_array = array(); + foreach ($direction['educationForms'] as $key => $educationForm){ + $budget_places_array[$key] = $educationForm['budget_places']; + } + $budget_places = '
'; + foreach ($budget_places_array as $key => $item){ + + $budget_places .= "$key - $item
"; + } + + $period_array = array(); + foreach ($direction['educationForms'] as $key => $period) { + $period_array[$key] = $period['period']; + } + $period = '
'; + foreach ($period_array as $key => $item) { + $period .= "$key - $item
"; + } + $profiles = ''; + //if (array_key_exists('educationalInstitution',$direction)) echo '+++++'; else echo '----'; + //exit(); + if (array_key_exists('educationalInstitution',$direction)) { + foreach ($direction['educationalInstitution'] as $educationalInstitution_name => $educationalInstitution) { + $profile_out = '
'; + $profiles .= "

{$educationalInstitution_name}

"; + foreach ($educationalInstitution as $profile_name => $profile) { + + foreach ($profile as $key => $value) { + $profile_out .= "{$key} - {$value['budget_places']}
"; + } + $tmp = str_replace(' ', '', $profile_name); + $profiles .= " +
+
+

+ +

+
+
+ $profile_out +
+
+
+
+ "; + } + }; + } + return "
@@ -39,8 +109,13 @@ class DirectonHtmlBuilder

{$direction['description']}

+

Бюджетные места:

{$profiles}
+
+ + +
@@ -52,12 +127,12 @@ class DirectonHtmlBuilder

Форма обучения: - {$educationForm} + $educationForms


Бюджетные места: - {$direction['budget_places']} + {$budget_places}


Квота: @@ -69,11 +144,11 @@ class DirectonHtmlBuilder


Стоимость платного обучения: - {$direction['cost_paid_place']} +


Период обучения (в годах): - {$direction['period']} + {$period}
diff --git a/resources/views/new-design/bakalavr-special.blade.php b/resources/views/new-design/bakalavr-special.blade.php index 8f936b0..28475bb 100644 --- a/resources/views/new-design/bakalavr-special.blade.php +++ b/resources/views/new-design/bakalavr-special.blade.php @@ -362,7 +362,20 @@ @php $napr = array(); foreach ($department->directions as $direction){ - $napr[$direction->name]['educationForm'][$direction->name . ' ' . $direction->id] = $direction->educationForm->name; + + + $napr[$direction->name]['educationForms'][$direction->educationForm->name]['budget_places'] = $direction->budget_places; + foreach($direction->directionProfiles as $profile) {$napr[$direction->name]['educationalInstitution'][$faculty->educationalInstitution->name][$profile->name][$direction->educationForm->name]['budget_places'] = $direction->budget_places; + } + + + $napr[$direction->name]['educationForms'][$direction->educationForm->name]['period'] = $direction->period; + + + + + + $napr[$direction->name]['id'] = $direction->id; $napr[$direction->name]['code'] = $direction->code; $napr[$direction->name]['educationLevel'] = $direction->educationLevel->name; @@ -378,21 +391,30 @@ @endphp - - @foreach($napr as $el) +{{-- @dd($napr)--}} + @foreach($napr as $el) {{ $el['name'] }} +{{-- @dd($el)--}} @php $DirectonHtmlBuilder = new DirectonHtmlBuilder($el); echo $DirectonHtmlBuilder->getHTML(); @endphp - {{ $el['code'] }} + {{ $el['code'] }} {{ $el['educationLevel'] }} - '; } ?> + @php + $educationForms = ''; + foreach ($el['educationForms'] as $key => $educationForm) { + $educationForms .= $key . ', '; + } + $educationForms = substr($educationForms, 0, -2); + + @endphp + {{$educationForms}} @endforeach @endforeach