Commit 18842830e4719ee2427e59b3569e2100af824eb3

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

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

Showing 10 changed files Side-by-side Diff

app/Enums/WorkerStatuses.php
... ... @@ -0,0 +1,36 @@
  1 +<?php
  2 +
  3 +namespace App\Enums;
  4 +
  5 +use App\Enums\EnumTraits\EnumToArray;
  6 +
  7 +enum WorkerStatuses: int
  8 +{
  9 + use EnumToArray;
  10 +
  11 + case NotIndicated = 1;
  12 + case LookingForWork = 0;
  13 + case NotLookingForWork = 2;
  14 + case ConsideringOffers = 3;
  15 +
  16 + public function label(): string
  17 + {
  18 + return match($this)
  19 + {
  20 + self::LookingForWork => 'Ищу работу',
  21 + self::NotIndicated => 'Не указано',
  22 + self::NotLookingForWork => 'Не ищу работу',
  23 + self::ConsideringOffers => 'Рассматриваю предложения',
  24 + };
  25 + }
  26 +
  27 + public static function getWorkerStatuses(): array {
  28 + $statuses_names = self::names();
  29 +
  30 + $result = [];
  31 + foreach ($statuses_names as $status_name){
  32 + $result[self::{$status_name}->value] = self::{$status_name}->label();
  33 + }
  34 + return $result;
  35 + }
  36 +}
app/Http/Controllers/Admin/UsersController.php
... ... @@ -63,7 +63,9 @@ class UsersController extends Controller
63 63 ->orWhere('telephone', 'LIKE', "%$find_key%");
64 64 }
65 65  
66   - $users = $users->Baseuser()->paginate(15);
  66 + $users = $users->Baseuser()
  67 + ->orderByDesc(Worker::select('created_at')->whereColumn('workers.user_id', 'users.id'))
  68 + ->paginate(15);
67 69  
68 70 if ($request->ajax()) {
69 71 return view('admin.users.index_bd_ajax', compact('users'));
app/Http/Controllers/Admin/WorkersController.php
... ... @@ -12,19 +12,12 @@ use App\Models\Worker;
12 12 use Carbon\Carbon;
13 13 use Illuminate\Database\Eloquent\Builder;
14 14 use Illuminate\Http\Request;
15   -use Illuminate\Support\Facades\DB;
16 15 use Illuminate\Support\Facades\Storage;
17 16 use Illuminate\Support\Facades\Validator;
  17 +use App\Enums\WorkerStatuses;
18 18  
19 19 class WorkersController extends Controller
20 20 {
21   -
22   - public $Status_work = [
23   - '0' => 'Не ищу работу',
24   - '1' => 'Ищу работу',
25   - '2' => 'Не указано'
26   - ];
27   -
28 21 public function index(Request $request) {
29 22 if ($request->ajax()) {
30 23 $user = User::find($request->id);
... ... @@ -69,7 +62,7 @@ class WorkersController extends Controller
69 62  
70 63 $users = $users->orderByDesc('id')->Realuser()->paginate(15);
71 64  
72   - $status_wor = $this->Status_work;
  65 + $status_wor = WorkerStatuses::getWorkerStatuses();
73 66  
74 67 if ($request->ajax()) {
75 68 return view('admin.worker.index_ajax', compact('users', 'status_wor'));
app/Http/Controllers/EmployerController.php
... ... @@ -596,7 +596,7 @@ class EmployerController extends Controller
596 596  
597 597 // Данные
598 598 $users = $users->Baseuser()->
599   - orderBy(Worker::select('position_work')->whereColumn('workers.user_id', 'users.id'));
  599 + orderByDesc(Worker::select('created_at')->whereColumn('workers.user_id', 'users.id'));
600 600 $count_users = $users;
601 601 $users = $users->paginate(5);
602 602  
app/Http/Controllers/WorkerController.php
... ... @@ -35,12 +35,11 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet;
35 35 use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
36 36 use Symfony\Component\HttpFoundation\StreamedResponse;
37 37 use App\Enums\DbExportColumns;
  38 +use App\Enums\WorkerStatuses;
38 39 use DateTime;
39 40  
40 41 class WorkerController extends Controller
41 42 {
42   - public $status_work = array(0 => 'Ищу работу', 1 => 'Не указано', 2 => 'Не ищу работу');
43   -
44 43 //профиль
45 44 public function profile(Worker $worker)
46 45 {
... ... @@ -81,8 +80,8 @@ class WorkerController extends Controller
81 80 }
82 81  
83 82 if ($look) {
84   - $status_work = $this->status_work;
85   - $resumes = Worker::query()->with('users')->with('job_titles');
  83 + $status_work = WorkerStatuses::getWorkerStatuses();
  84 + $resumes = Worker::query()->with('users')->with('job_titles')->orderByDesc('updated_at');;
86 85 $resumes = $resumes->whereHas('users', function (Builder $query) {
87 86 $query->Where('is_worker', '=', '1')
88 87 ->Where('is_bd', '=', '0');
... ... @@ -103,27 +102,14 @@ class WorkerController extends Controller
103 102 if ($request->get('sort')) {
104 103 $sort = $request->get('sort');
105 104 switch ($sort) {
106   - case 'name_up':
107   - $resumes = $resumes->orderBy(User::select('surname')
108   - ->whereColumn('workers.user_id', 'users.id')
109   - );
110   - break;
111   - case 'name_down':
112   - $resumes = $resumes->orderByDesc(User::select('surname')
113   - ->whereColumn('workers.user_id', 'users.id')
114   - );
115   - break;
116   - case 'created_at_up':
117   - $resumes = $resumes->OrderBy('created_at')->orderBy('id');
118   - break;
119   - case 'created_at_down':
120   - $resumes = $resumes->orderByDesc('created_at')->orderBy('id');
  105 + case 'looking_for_work':
  106 + $resumes->where('status_work', '=', WorkerStatuses::LookingForWork->value);
121 107 break;
122   - case 'default':
123   - $resumes = $resumes->orderBy('id')->orderby('updated_at');
  108 + case 'considering_offers':
  109 + $resumes->where('status_work', '=', WorkerStatuses::ConsideringOffers->value);
124 110 break;
125   - default:
126   - $resumes = $resumes->orderBy('id')->orderby('updated_at');
  111 + case 'not_looking_for_work':
  112 + $resumes->where('status_work', '=', WorkerStatuses::NotLookingForWork->value);
127 113 break;
128 114 }
129 115 }
... ... @@ -208,7 +194,7 @@ class WorkerController extends Controller
208 194 $idiot = 0;
209 195 }
210 196  
211   - $status_work = $this->status_work;
  197 + $status_work = WorkerStatuses::getWorkerStatuses();
212 198 $Query = Worker::query()->with('users')->with('job_titles')
213 199 ->with('place_worker')->with('sertificate')->with('prev_company')
214 200 ->with('infobloks')->with('response');
... ... @@ -245,7 +231,7 @@ class WorkerController extends Controller
245 231 // скачать анкету соискателя
246 232 public function resume_download(Worker $worker)
247 233 {
248   - $status_work = $this->status_work;
  234 + $status_work = WorkerStatuses::getWorkerStatuses();
249 235 $Query = Worker::query()->with('users')->with('job_titles')
250 236 ->with('place_worker')->with('sertificate')->with('prev_company')
251 237 ->with('infobloks');
... ... @@ -254,7 +240,7 @@ class WorkerController extends Controller
254 240  
255 241 view()->share('Query',$Query);
256 242  
257   - $status_work = $this->status_work;
  243 + $status_work = WorkerStatuses::getWorkerStatuses();
258 244 $infoblocks = infobloks::query()->get();
259 245  
260 246 //return view('layout.pdf', compact('Query', 'status_work', 'infoblocks'));
... ... @@ -390,7 +376,7 @@ class WorkerController extends Controller
390 376 $persent5 = 5;
391 377 }
392 378  
393   - $status_work = $this->status_work;
  379 + $status_work = WorkerStatuses::getWorkerStatuses();
394 380 $additional_document_statuses = [0 => 'Не указано', 1 => 'В наличии', 2 => 'Отсутствует'];
395 381 $info_blocks = infobloks::query()->OrderBy('name')->get();
396 382  
resources/views/employers/favorite.blade.php
... ... @@ -149,10 +149,10 @@
149 149 <div class="cvs__item-text-row">
150 150 <div class="flex" style="align-items: start;">
151 151 <div class="cvs__item-text-status @if ($it->status_work == 0) looking-for-job @endif">
152   - @if ($it->status_work == 0) Ищу работу
153   - @elseif ($it->status_work == 1) Не указано
154   - @elseif ($it->status_work == 2) Не ищу работу
155   - @endif
  152 + @php
  153 + $worker_statuses = App\Enums\WorkerStatuses::getWorkerStatuses();
  154 + @endphp
  155 + {{ $worker_statuses[$it->status_work] }}
156 156 </div>
157 157 <div class="cvs__item-text-updated-at">
158 158 Обновлено: {{ date('d.m.Y', strtotime($it->updated_at)) }}
resources/views/info_company_new.blade.php
... ... @@ -120,9 +120,10 @@
120 120 Написать сообщение
121 121 </a>
122 122 @else
123   - <a data-fancybox data-src="#question" data-options='{"touch":false,"autoFocus":false}' class="js_send_it_button button">
  123 + <button type="button" data-fancybox data-src="#send" data-vacancy="0" data-uid="{{ $user_id }}" data-tuid="{{ $company[0]->users->id }}" data-options='{"touch":false,"autoFocus":false}'
  124 + class="button js_send_it_button">
124 125 Написать сообщение
125   - </a>
  126 + </button>
126 127 @endif
127 128 </div>
128 129 </div>
resources/views/layout/pdf-list-people.blade.php
... ... @@ -246,8 +246,12 @@
246 246 <tr>
247 247 <td>Статус:</td>
248 248 <td>
249   - @php $code = $Q['status_work']; @endphp
250   - <b>@if ($code == 0) Ищу работу @elseif($code == 1) Не указано @else Не ищу работу @endif</b></td>
  249 + @php
  250 + $worker_statuses = App\Enums\WorkerStatuses::getWorkerStatuses();
  251 + $code = $Q['status_work'];
  252 + @endphp
  253 + <b>{{ $worker_statuses[$code] }}</b>
  254 + </td>
251 255 </tr>
252 256 <tr>
253 257 <td>Город проживания:</td>
resources/views/resume.blade.php
... ... @@ -240,11 +240,10 @@
240 240 <div class="filters__body">
241 241 <div class="select filters__select">
242 242 <select class="js-select2" id="sort_ajax" name="sort_ajax">
243   - <option value="default">Сортировка (по умолчанию)</option>
244   - <option value="name_up">По имени (возрастание)</option>
245   - <option value="name_down">По имени (убывание)</option>
246   - <option value="created_at_up">По дате (возрастание)</option>
247   - <option value="created_at_down">По дате (убывание)</option>
  243 + <option value="all_workers">Все кандидаты</option>
  244 + <option value="looking_for_work">Ищу работу</option>
  245 + <option value="considering_offers">Рассматриваю предложения</option>
  246 + <option value="not_looking_for_work">Не ищу работу</option>
248 247 </select>
249 248 </div>
250 249 </div>
resources/views/workers/form_basic_information.blade.php
... ... @@ -47,9 +47,9 @@
47 47 <div class="form-group__item">
48 48 <div class="select">
49 49 <select class="js-select2" name="status_work" id="status_work">
50   - <option value="1" @if ($worker->status_work == 1) selected @endif>Не указано</option>
51   - <option value="2" @if ($worker->status_work == 2) selected @endif>Не ищу работу</option>
52   - <option value="0" @if ($worker->status_work == 0) selected @endif>Ищу работу</option>
  50 + @foreach(App\Enums\WorkerStatuses::getWorkerStatuses() as $status_id => $status_label)
  51 + <option value="{{ $status_id }}" @if ($worker->status_work == $status_id) selected @endif> {{ $status_label }} </option>
  52 + @endforeach
53 53 </select>
54 54 </div>
55 55 </div>