Commit 653a45883d97a164408161df858de5d0b4f897c9

Authored by Андрей Ларионов
Exists in master

Merge branch 'master' of http://gitlab.nologostudio.ru/alarionov/rekamore-su

Showing 14 changed files Side-by-side Diff

app/Enums/EnumTraits/EnumToArray.php
... ... @@ -0,0 +1,11 @@
  1 +<?php
  2 +
  3 +namespace App\Enums\EnumTraits;
  4 +
  5 +trait EnumToArray
  6 +{
  7 + public static function values(): array
  8 + {
  9 + return array_column(self::cases(), 'value');
  10 + }
  11 +}
app/Enums/MainPageCounters.php
... ... @@ -0,0 +1,14 @@
  1 +<?php
  2 +
  3 +namespace App\Enums;
  4 +
  5 +use App\Enums\EnumTraits\EnumToArray;
  6 +
  7 +enum MainPageCounters: string
  8 +{
  9 + use EnumToArray;
  10 +
  11 + case ResumeMain = 'first_main';
  12 + case VacanciesMain = 'second_main';
  13 + case CompaniesMain = 'third_main';
  14 +}
app/Http/Controllers/Admin/CompanyController.php
... ... @@ -15,8 +15,10 @@ use App\Models\job_titles_main;
15 15 use App\Models\pages;
16 16 use App\Models\reclame;
17 17 use App\Models\SEO;
  18 +use App\Models\PageContent;
18 19 use Illuminate\Http\Request;
19 20 use Illuminate\Support\Facades\Storage;
  21 +use App\Enums\MainPageCounters;
20 22  
21 23 class CompanyController extends Controller
22 24 {
... ... @@ -43,6 +45,31 @@ class CompanyController extends Controller
43 45 }
44 46 }
45 47  
  48 + // кабинет - блок со счетчиками на главной
  49 + public function counters_main(Request $request) {
  50 + $block_names = MainPageCounters::values();
  51 + $blocks = PageContent::select('name', 'title', 'description', 'extra')
  52 + ->whereIn('name', $block_names)
  53 + ->get()
  54 + ->keyBy('name')
  55 + ->toArray();
  56 + return view('admin.counters_main.index', compact('block_names', 'blocks'));
  57 + }
  58 +
  59 + public function counters_main_update(Request $request, string $name) {
  60 + PageContent::updateOrCreate(
  61 + ['name' => $name],
  62 + array_merge(['name' => $name], $request->all())
  63 + );
  64 + $block_names = MainPageCounters::values();;
  65 + $blocks = PageContent::select('name', 'title', 'description', 'extra')
  66 + ->whereIn('name', $block_names)
  67 + ->get()
  68 + ->keyBy('name')
  69 + ->toArray();
  70 + return view('admin.counters_main.index', compact('block_names', 'blocks'));
  71 + }
  72 +
46 73 ////////////////////////////////////////////////////////////////////////////////
47 74 // кабинет - редактор шапки-футера сайта
48 75 public function editblocks(Request $request) {
app/Http/Controllers/MainController.php
... ... @@ -10,7 +10,6 @@ use App\Models\Ad_employer;
10 10 use App\Models\Ad_jobs;
11 11 use App\Models\Category;
12 12 use App\Models\Education;
13   -use App\Models\Employer;
14 13 use App\Models\employers_main;
15 14 use App\Models\Job_title;
16 15 use App\Models\Like_vacancy;
... ... @@ -25,7 +24,8 @@ use Illuminate\Support\Facades\DB;
25 24 use Illuminate\Support\Facades\Hash;
26 25 use Illuminate\Support\Facades\Mail;
27 26 use Illuminate\Support\Facades\Validator;
28   -use App\Classes\StatusUser;
  27 +use App\Models\PageContent;
  28 +use App\Enums\MainPageCounters;
29 29  
30 30 class MainController extends Controller
31 31 {
... ... @@ -96,7 +96,16 @@ class MainController extends Controller
96 96 })->
97 97 orderBy('sort')->get();
98 98 $vacancy = Ad_jobs::query()->with('job_title')->orderBy('position_ship')->get();
99   - return view('index', compact('news', 'Job_title', 'categories', 'employers', 'vacancy', 'Main_Job'));
  99 +
  100 + $block_names = MainPageCounters::values();;
  101 + $blocks_counters = PageContent::select('name', 'title', 'description', 'extra')
  102 + ->whereIn('name', $block_names)
  103 + ->orderBy('name', 'asc')
  104 + ->get()
  105 + ->keyBy('name')
  106 + ->toArray();
  107 +
  108 + return view('index', compact('news', 'Job_title', 'categories', 'employers', 'vacancy', 'Main_Job', 'blocks_counters'));
100 109 }
101 110  
102 111 public function search_vacancies(Request $request) {
app/Models/PageContent.php
... ... @@ -0,0 +1,18 @@
  1 +<?php
  2 +
  3 +namespace App\Models;
  4 +
  5 +use Illuminate\Database\Eloquent\Factories\HasFactory;
  6 +use Illuminate\Database\Eloquent\Model;
  7 +
  8 +class PageContent extends Model
  9 +{
  10 + use HasFactory;
  11 +
  12 + protected $fillable = [
  13 + 'name',
  14 + 'title',
  15 + 'description',
  16 + 'extra'
  17 + ];
  18 +}
... ... @@ -57,7 +57,7 @@ return [
57 57 'prefix' => '',
58 58 'prefix_indexes' => true,
59 59 'strict' => true,
60   - 'engine' => null,
  60 + 'engine' => 'InnoDB ROW_FORMAT=DYNAMIC',
61 61 'options' => extension_loaded('pdo_mysql') ? array_filter([
62 62 PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
63 63 ]) : [],
database/migrations/2024_06_18_110133_create_page_contents_table.php
... ... @@ -0,0 +1,35 @@
  1 +<?php
  2 +
  3 +use Illuminate\Database\Migrations\Migration;
  4 +use Illuminate\Database\Schema\Blueprint;
  5 +use Illuminate\Support\Facades\Schema;
  6 +
  7 +return new class extends Migration
  8 +{
  9 + /**
  10 + * Run the migrations.
  11 + *
  12 + * @return void
  13 + */
  14 + public function up()
  15 + {
  16 + Schema::create('page_contents', function (Blueprint $table) {
  17 + $table->id();
  18 + $table->string('name')->unique();
  19 + $table->string('title');
  20 + $table->string('description');
  21 + $table->string('extra');
  22 + $table->timestamps();
  23 + });
  24 + }
  25 +
  26 + /**
  27 + * Reverse the migrations.
  28 + *
  29 + * @return void
  30 + */
  31 + public function down()
  32 + {
  33 + Schema::dropIfExists('page_contents');
  34 + }
  35 +};
resources/views/TITLE_TEXT.blade.php
... ... @@ -1,18 +0,0 @@
1   -<div class="numbers__item">
2   - <b>555+</b>
3   - <span>Резюме</span>
4   - Банальные, но неопровержимые выводы, а также элементы политического процесса лишь добавляют
5   - фракционных разногласий и призваны к ответу.
6   -</div>
7   -<div class="numbers__item">
8   - <b>1 001+</b>
9   - <span>Вакансий</span>
10   - В рамках спецификации современных стандартов, диаграммы связей заблокированы в рамках своих
11   - собственных рациональных ограничений.
12   -</div>
13   -<div class="numbers__item">
14   - <b>265</b>
15   - <span>Компаний</span>
16   - Но сторонники тоталитаризма в науке заблокированы в рамках своих собственных рациональных
17   - ограничений.
18   -</div>
resources/views/admin/counters_main/form.blade.php
... ... @@ -0,0 +1,47 @@
  1 +<div class="px-4 py-3 mb-8 bg-white rounded-lg shadow-md dark:bg-gray-800">
  2 + <label class="block text-sm">
  3 + <span class="text-gray-700 dark:text-gray-400">Цифра</span>
  4 + <input name="extra" id="extra" required
  5 + class="block w-full mt-1 text-sm dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray form-input"
  6 + placeholder="Цифра" value="{{$blocks[$block_name]['extra'] ?? ''}}"
  7 + />
  8 + @error('extra')
  9 + <span class="text-xs text-red-600 dark:text-red-400">
  10 + {{ $message }}
  11 + </span>
  12 + @enderror
  13 + </label><br>
  14 +
  15 + <label class="block text-sm">
  16 + <span class="text-gray-700 dark:text-gray-400">Подзаголовок</span>
  17 + <input name="title" id="title" required
  18 + class="block w-full mt-1 text-sm dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray form-input"
  19 + placeholder="Подзаголовок" value="{{$blocks[$block_name]['title'] ?? ''}}"
  20 + />
  21 + @error('title')
  22 + <span class="text-xs text-red-600 dark:text-red-400">
  23 + {{ $message }}
  24 + </span>
  25 + @enderror
  26 + </label><br>
  27 +
  28 + <label class="block text-sm">
  29 + <span class="text-gray-700 dark:text-gray-400">Описание</span>
  30 + <textarea name="description" id="description" required
  31 + class="block w-full mt-1 text-sm dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray form-input"
  32 + placeholder="Описание" value="{{$blocks[$block_name]['description'] ?? ''}}"
  33 + >{{$blocks[$block_name]['description'] ?? ''}}</textarea>
  34 + @error('description')
  35 + <span class="text-xs text-red-600 dark:text-red-400">
  36 + {{ $message }}
  37 + </span>
  38 + @enderror
  39 + </label><br>
  40 +
  41 + <div class="flex flex-col flex-wrap mb-4 space-y-4 md:flex-row md:items-end md:space-x-4">
  42 + <button type="submit" class="px-3 py-1 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-md active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple">
  43 + Сохранить
  44 + </button>
  45 + </div>
  46 +
  47 +</div>
resources/views/admin/counters_main/index.blade.php
... ... @@ -0,0 +1,10 @@
  1 +@extends('layout.admin', ['title' => 'Админка - Редактор счетчиков на главной странице'])
  2 +
  3 +@section('content')
  4 + @foreach ($block_names as $block_name)
  5 + <form method="POST" action="{{ route('admin.counters-main-update', ['name' => $block_name]) }}">
  6 + @csrf
  7 + @include('admin.counters_main.form')
  8 + </form>
  9 + @endforeach
  10 +@endsection
resources/views/employers/bd.blade.php
... ... @@ -105,62 +105,48 @@
105 105 $categories = 0;
106 106  
107 107 @endphp
  108 +
108 109 @if ($users->count())
109 110 @foreach ($users as $key => $it)
110   - @if (isset($it->workers[0]->position_work))
111   - @if ($categories !== $it->workers[0]->position_work)
112   - @php
113   - $categories = $it->workers[0]->position_work;
114   - $i = 0;
115   - @endphp
116   - @endif
117   -
118   - @if ($i == 0)
119   -
120   - @endif
121   - <tr>
122   - <td>{{ $it->surname." ".$it->name_man }}<br>{{ $it->surname2 }}</td>
123   -
124   - <td>
125   -
126   - @if (!empty($it->workers[0]->telephone))
127   - <a href="tel:{{ $it->workers[0]->telephone }}">
128   - {{ $it->workers[0]->telephone }}
129   - </a>
130   - @else
131   - -
132   - @endif
133   -
134   - @if (!empty($it->workers[0]->telephone2))
135   - <br><a href="tel:{{ $it->workers[0]->telephone2 }}">
136   - {{ $it->workers[0]->telephone2 }}
137   - </a>
138   - @endif
139   - </td>
140   -
141   - <td>
142   - @if (!empty($it->workers[0]->email))
143   - <a href="emailto:{{ $it->workers[0]->email }}">{{ $it->workers[0]->email }}</a>
144   - @else
145   - -
146   - @endif
147   - </td>
148   -
149   - <td>
150   - @if (isset($it->workers[0]->id))
151   - <a href="{{ route('resume_download', ['worker' => $it->workers[0]->id]) }}" class="table__link">
152   - <svg>
153   - <use xlink:href="{{ asset('images/sprite.svg#share') }}"></use>
154   - </svg>
155   - Скачать
156   - </a>
157   - @endif
158   - </td>
159   - </tr>
160   - @php $i++ @endphp
161   -
162   -
163   - @endif
  111 + <tr>
  112 + <td>{{ $it->surname." ".$it->name_man }}<br>{{ $it->surname2 }}</td>
  113 +
  114 + <td>
  115 +
  116 + @if (!empty($it->workers[0]->telephone))
  117 + <a href="tel:{{ $it->workers[0]->telephone }}">
  118 + {{ $it->workers[0]->telephone }}
  119 + </a>
  120 + @else
  121 + -
  122 + @endif
  123 +
  124 + @if (!empty($it->workers[0]->telephone2))
  125 + <br><a href="tel:{{ $it->workers[0]->telephone2 }}">
  126 + {{ $it->workers[0]->telephone2 }}
  127 + </a>
  128 + @endif
  129 + </td>
  130 +
  131 + <td>
  132 + @if (!empty($it->workers[0]->email))
  133 + <a href="emailto:{{ $it->workers[0]->email }}">{{ $it->workers[0]->email }}</a>
  134 + @else
  135 + -
  136 + @endif
  137 + </td>
  138 +
  139 + <td>
  140 + @if (isset($it->workers[0]->id))
  141 + <a href="{{ route('resume_download', ['worker' => $it->workers[0]->id]) }}" class="table__link">
  142 + <svg>
  143 + <use xlink:href="{{ asset('images/sprite.svg#share') }}"></use>
  144 + </svg>
  145 + Скачать
  146 + </a>
  147 + @endif
  148 + </td>
  149 + </tr>
164 150 @endforeach
165 151 @endif
166 152 </tbody>
resources/views/index.blade.php
... ... @@ -66,13 +66,23 @@
66 66 </div>
67 67 </div>
68 68 </section>
  69 +
  70 +@if ($blocks_counters)
69 71 <section class="numbers">
70 72 <div class="container">
71 73 <div class="numbers__body">
72   - @include('TITLE_TEXT')
  74 + @foreach($blocks_counters as $block_counter)
  75 + <div class="numbers__item">
  76 + <b>{{$block_counter['extra']}}</b>
  77 + <span>{{$block_counter['title']}}</span>
  78 + {{$block_counter['description']}}
  79 + </div>
  80 + @endforeach
73 81 </div>
74 82 </div>
75 83 </section>
  84 +@endif
  85 +
76 86 <!--<section class="vacancies">
77 87 <div class="container">
78 88 <div class="title"><h4>Новые вакансии</h4></div>
resources/views/layout/admin.blade.php
... ... @@ -693,6 +693,15 @@
693 693 @endif
694 694 @endif
695 695  
  696 + @if ($cont->url_page == "admin/job-titles-main")
  697 + @if ((($cont->is_admin == 1) && ($admin == 1)) ||
  698 + (($cont->is_manager == 1) && ($is_manager == 1)))
  699 + <li class="px-2 py-1 transition-colors duration-150 hover:text-gray-800 dark:hover:text-gray-200 {{ Request::routeIs('admin.counters-main') ? 'dark:text-gray-100' : null }}">
  700 + <a class="w-full" href="{{ route('admin.counters-main') }}">Счетчики на главной</a>
  701 + </li>
  702 + @endif
  703 + @endif
  704 +
696 705 @if ($cont->url_page == "admin/employers-main")
697 706 @if ((($cont->is_admin == 1) && ($admin == 1)) ||
698 707 (($cont->is_manager == 1) && ($is_manager == 1)))
... ... @@ -327,6 +327,10 @@ Route::group([
327 327 // кабинет - редактор должности на главной
328 328 Route::get('job-titles-main', [CompanyController::class, 'job_titles_main'])->name('job-titles-main');
329 329  
  330 + // кабинет - счетчики на главной
  331 + Route::get('counters-main', [CompanyController::class, 'counters_main'])->name('counters-main');
  332 + Route::post('counters-main/edit/{name}', [CompanyController::class, 'counters_main_update'])->name('counters-main-update');
  333 +
330 334 // кабинет - редактор работодатели на главной
331 335 Route::get('employers-main', [CompanyController::class, 'employers_main'])->name('employers-main');
332 336