From 3b2e8c4eb29eddd5e8fe3a5bd34284e30726da44 Mon Sep 17 00:00:00 2001 From: Sergey Panarin Date: Wed, 19 Jun 2024 11:12:00 +0200 Subject: [PATCH] =?UTF-8?q?=D1=80=D0=B5=D0=B4=D0=B0=D0=BA=D1=82=D0=B8=D1=80=D0?= =?UTF-8?q?=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=B1=D0=BB=D0=BE=D0=BB=D0=BA?= =?UTF-8?q?=D0=BE=D0=BC=20=D0=BD=D0=B0=20=D0=B3=D0=BB=D0=B0=D0=B2=D0=BD=D0=BE?= =?UTF-8?q?=D0=B9=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Enums/EnumTraits/EnumToArray.php | 11 +++ app/Enums/MainPageCounters.php | 14 +++ app/Http/Controllers/Admin/CompanyController.php | 27 ++++++ app/Http/Controllers/MainController.php | 15 +++- app/Models/PageContent.php | 18 ++++ config/database.php | 2 +- ...024_06_18_110133_create_page_contents_table.php | 35 ++++++++ resources/views/TITLE_TEXT.blade.php | 18 ---- resources/views/admin/counters_main/form.blade.php | 47 ++++++++++ .../views/admin/counters_main/index.blade.php | 10 +++ resources/views/employers/bd.blade.php | 94 +++++++++----------- resources/views/index.blade.php | 12 ++- resources/views/layout/admin.blade.php | 9 ++ routes/web.php | 4 + 14 files changed, 239 insertions(+), 77 deletions(-) create mode 100644 app/Enums/EnumTraits/EnumToArray.php create mode 100644 app/Enums/MainPageCounters.php create mode 100644 app/Models/PageContent.php create mode 100644 database/migrations/2024_06_18_110133_create_page_contents_table.php delete mode 100644 resources/views/TITLE_TEXT.blade.php create mode 100644 resources/views/admin/counters_main/form.blade.php create mode 100644 resources/views/admin/counters_main/index.blade.php diff --git a/app/Enums/EnumTraits/EnumToArray.php b/app/Enums/EnumTraits/EnumToArray.php new file mode 100644 index 0000000..9c37688 --- /dev/null +++ b/app/Enums/EnumTraits/EnumToArray.php @@ -0,0 +1,11 @@ +whereIn('name', $block_names) + ->get() + ->keyBy('name') + ->toArray(); + return view('admin.counters_main.index', compact('block_names', 'blocks')); + } + + public function counters_main_update(Request $request, string $name) { + PageContent::updateOrCreate( + ['name' => $name], + array_merge(['name' => $name], $request->all()) + ); + $block_names = MainPageCounters::values();; + $blocks = PageContent::select('name', 'title', 'description', 'extra') + ->whereIn('name', $block_names) + ->get() + ->keyBy('name') + ->toArray(); + return view('admin.counters_main.index', compact('block_names', 'blocks')); + } + //////////////////////////////////////////////////////////////////////////////// // кабинет - редактор шапки-футера сайта public function editblocks(Request $request) { diff --git a/app/Http/Controllers/MainController.php b/app/Http/Controllers/MainController.php index 38f21d5..1c67f58 100644 --- a/app/Http/Controllers/MainController.php +++ b/app/Http/Controllers/MainController.php @@ -10,7 +10,6 @@ use App\Models\Ad_employer; use App\Models\Ad_jobs; use App\Models\Category; use App\Models\Education; -use App\Models\Employer; use App\Models\employers_main; use App\Models\Job_title; use App\Models\Like_vacancy; @@ -25,7 +24,8 @@ use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Validator; -use App\Classes\StatusUser; +use App\Models\PageContent; +use App\Enums\MainPageCounters; class MainController extends Controller { @@ -96,7 +96,16 @@ class MainController extends Controller })-> orderBy('sort')->get(); $vacancy = Ad_jobs::query()->with('job_title')->orderBy('position_ship')->get(); - return view('index', compact('news', 'Job_title', 'categories', 'employers', 'vacancy', 'Main_Job')); + + $block_names = MainPageCounters::values();; + $blocks_counters = PageContent::select('name', 'title', 'description', 'extra') + ->whereIn('name', $block_names) + ->orderBy('name', 'asc') + ->get() + ->keyBy('name') + ->toArray(); + + return view('index', compact('news', 'Job_title', 'categories', 'employers', 'vacancy', 'Main_Job', 'blocks_counters')); } public function search_vacancies(Request $request) { diff --git a/app/Models/PageContent.php b/app/Models/PageContent.php new file mode 100644 index 0000000..86386a2 --- /dev/null +++ b/app/Models/PageContent.php @@ -0,0 +1,18 @@ + '', 'prefix_indexes' => true, 'strict' => true, - 'engine' => null, + 'engine' => 'InnoDB ROW_FORMAT=DYNAMIC', 'options' => extension_loaded('pdo_mysql') ? array_filter([ PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), ]) : [], diff --git a/database/migrations/2024_06_18_110133_create_page_contents_table.php b/database/migrations/2024_06_18_110133_create_page_contents_table.php new file mode 100644 index 0000000..28eb6c2 --- /dev/null +++ b/database/migrations/2024_06_18_110133_create_page_contents_table.php @@ -0,0 +1,35 @@ +id(); + $table->string('name')->unique(); + $table->string('title'); + $table->string('description'); + $table->string('extra'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('page_contents'); + } +}; diff --git a/resources/views/TITLE_TEXT.blade.php b/resources/views/TITLE_TEXT.blade.php deleted file mode 100644 index 83ecec1..0000000 --- a/resources/views/TITLE_TEXT.blade.php +++ /dev/null @@ -1,18 +0,0 @@ -
- 555+ - Резюме - Банальные, но неопровержимые выводы, а также элементы политического процесса лишь добавляют - фракционных разногласий и призваны к ответу. -
-
- 1 001+ - Вакансий - В рамках спецификации современных стандартов, диаграммы связей заблокированы в рамках своих - собственных рациональных ограничений. -
-
- 265 - Компаний - Но сторонники тоталитаризма в науке заблокированы в рамках своих собственных рациональных - ограничений. -
diff --git a/resources/views/admin/counters_main/form.blade.php b/resources/views/admin/counters_main/form.blade.php new file mode 100644 index 0000000..a2037a1 --- /dev/null +++ b/resources/views/admin/counters_main/form.blade.php @@ -0,0 +1,47 @@ +
+
+ +
+ +
+ +
+ +
+ +
diff --git a/resources/views/admin/counters_main/index.blade.php b/resources/views/admin/counters_main/index.blade.php new file mode 100644 index 0000000..45ffb7b --- /dev/null +++ b/resources/views/admin/counters_main/index.blade.php @@ -0,0 +1,10 @@ +@extends('layout.admin', ['title' => 'Админка - Редактор счетчиков на главной странице']) + +@section('content') + @foreach ($block_names as $block_name) +
+ @csrf + @include('admin.counters_main.form') +
+ @endforeach +@endsection diff --git a/resources/views/employers/bd.blade.php b/resources/views/employers/bd.blade.php index e5fa28c..e680165 100644 --- a/resources/views/employers/bd.blade.php +++ b/resources/views/employers/bd.blade.php @@ -105,62 +105,48 @@ $categories = 0; @endphp + @if ($users->count()) @foreach ($users as $key => $it) - @if (isset($it->workers[0]->position_work)) - @if ($categories !== $it->workers[0]->position_work) - @php - $categories = $it->workers[0]->position_work; - $i = 0; - @endphp - @endif - - @if ($i == 0) - - @endif - - {{ $it->surname." ".$it->name_man }}
{{ $it->surname2 }} - - - - @if (!empty($it->workers[0]->telephone)) - - {{ $it->workers[0]->telephone }} - - @else - - - @endif - - @if (!empty($it->workers[0]->telephone2)) -
- {{ $it->workers[0]->telephone2 }} - - @endif - - - - @if (!empty($it->workers[0]->email)) - {{ $it->workers[0]->email }} - @else - - - @endif - - - - @if (isset($it->workers[0]->id)) - - - - - Скачать - - @endif - - - @php $i++ @endphp - - - @endif + + {{ $it->surname." ".$it->name_man }}
{{ $it->surname2 }} + + + + @if (!empty($it->workers[0]->telephone)) + + {{ $it->workers[0]->telephone }} + + @else + - + @endif + + @if (!empty($it->workers[0]->telephone2)) +
+ {{ $it->workers[0]->telephone2 }} + + @endif + + + + @if (!empty($it->workers[0]->email)) + {{ $it->workers[0]->email }} + @else + - + @endif + + + + @if (isset($it->workers[0]->id)) + + + + + Скачать + + @endif + + @endforeach @endif diff --git a/resources/views/index.blade.php b/resources/views/index.blade.php index 05eaf4c..8cb921a 100644 --- a/resources/views/index.blade.php +++ b/resources/views/index.blade.php @@ -66,13 +66,23 @@ + +@if ($blocks_counters)
- @include('TITLE_TEXT') + @foreach($blocks_counters as $block_counter) +
+ {{$block_counter['extra']}} + {{$block_counter['title']}} + {{$block_counter['description']}} +
+ @endforeach
+@endif +