From 0388bf4f0bfbd177e849f8377e155f8646717e22 Mon Sep 17 00:00:00 2001 From: Sergey Panarin Date: Tue, 16 Jul 2024 09:23:38 +0200 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D1=87=D0=B8=2044,46,48?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Enums/WorkerStatuses.php | 36 ++++++++++++++++++ app/Http/Controllers/Admin/UsersController.php | 4 +- app/Http/Controllers/Admin/WorkersController.php | 11 +----- app/Http/Controllers/EmployerController.php | 2 +- app/Http/Controllers/WorkerController.php | 40 +++++++------------- resources/views/employers/favorite.blade.php | 8 ++-- resources/views/info_company_new.blade.php | 5 ++- resources/views/layout/pdf-list-people.blade.php | 8 +++- resources/views/resume.blade.php | 9 ++--- .../views/workers/form_basic_information.blade.php | 6 +-- 10 files changed, 75 insertions(+), 54 deletions(-) create mode 100644 app/Enums/WorkerStatuses.php diff --git a/app/Enums/WorkerStatuses.php b/app/Enums/WorkerStatuses.php new file mode 100644 index 0000000..529e85c --- /dev/null +++ b/app/Enums/WorkerStatuses.php @@ -0,0 +1,36 @@ + 'Ищу работу', + self::NotIndicated => 'Не указано', + self::NotLookingForWork => 'Не ищу работу', + self::ConsideringOffers => 'Рассматриваю предложения', + }; + } + + public static function getWorkerStatuses(): array { + $statuses_names = self::names(); + + $result = []; + foreach ($statuses_names as $status_name){ + $result[self::{$status_name}->value] = self::{$status_name}->label(); + } + return $result; + } +} diff --git a/app/Http/Controllers/Admin/UsersController.php b/app/Http/Controllers/Admin/UsersController.php index 394d6d5..ebacd2f 100644 --- a/app/Http/Controllers/Admin/UsersController.php +++ b/app/Http/Controllers/Admin/UsersController.php @@ -63,7 +63,9 @@ class UsersController extends Controller ->orWhere('telephone', 'LIKE', "%$find_key%"); } - $users = $users->Baseuser()->paginate(15); + $users = $users->Baseuser() + ->orderByDesc(Worker::select('created_at')->whereColumn('workers.user_id', 'users.id')) + ->paginate(15); if ($request->ajax()) { return view('admin.users.index_bd_ajax', compact('users')); diff --git a/app/Http/Controllers/Admin/WorkersController.php b/app/Http/Controllers/Admin/WorkersController.php index 5e59621..81c9b92 100644 --- a/app/Http/Controllers/Admin/WorkersController.php +++ b/app/Http/Controllers/Admin/WorkersController.php @@ -12,19 +12,12 @@ use App\Models\Worker; use Carbon\Carbon; use Illuminate\Database\Eloquent\Builder; use Illuminate\Http\Request; -use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Validator; +use App\Enums\WorkerStatuses; class WorkersController extends Controller { - - public $Status_work = [ - '0' => 'Не ищу работу', - '1' => 'Ищу работу', - '2' => 'Не указано' - ]; - public function index(Request $request) { if ($request->ajax()) { $user = User::find($request->id); @@ -69,7 +62,7 @@ class WorkersController extends Controller $users = $users->orderByDesc('id')->Realuser()->paginate(15); - $status_wor = $this->Status_work; + $status_wor = WorkerStatuses::getWorkerStatuses(); if ($request->ajax()) { return view('admin.worker.index_ajax', compact('users', 'status_wor')); diff --git a/app/Http/Controllers/EmployerController.php b/app/Http/Controllers/EmployerController.php index 5c341a5..04f550f 100644 --- a/app/Http/Controllers/EmployerController.php +++ b/app/Http/Controllers/EmployerController.php @@ -596,7 +596,7 @@ class EmployerController extends Controller // Данные $users = $users->Baseuser()-> - orderBy(Worker::select('position_work')->whereColumn('workers.user_id', 'users.id')); + orderByDesc(Worker::select('created_at')->whereColumn('workers.user_id', 'users.id')); $count_users = $users; $users = $users->paginate(5); diff --git a/app/Http/Controllers/WorkerController.php b/app/Http/Controllers/WorkerController.php index 2726f4e..7de9bc9 100644 --- a/app/Http/Controllers/WorkerController.php +++ b/app/Http/Controllers/WorkerController.php @@ -35,12 +35,11 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; use Symfony\Component\HttpFoundation\StreamedResponse; use App\Enums\DbExportColumns; +use App\Enums\WorkerStatuses; use DateTime; class WorkerController extends Controller { - public $status_work = array(0 => 'Ищу работу', 1 => 'Не указано', 2 => 'Не ищу работу'); - //профиль public function profile(Worker $worker) { @@ -81,8 +80,8 @@ class WorkerController extends Controller } if ($look) { - $status_work = $this->status_work; - $resumes = Worker::query()->with('users')->with('job_titles'); + $status_work = WorkerStatuses::getWorkerStatuses(); + $resumes = Worker::query()->with('users')->with('job_titles')->orderByDesc('updated_at');; $resumes = $resumes->whereHas('users', function (Builder $query) { $query->Where('is_worker', '=', '1') ->Where('is_bd', '=', '0'); @@ -103,27 +102,14 @@ class WorkerController extends Controller if ($request->get('sort')) { $sort = $request->get('sort'); switch ($sort) { - case 'name_up': - $resumes = $resumes->orderBy(User::select('surname') - ->whereColumn('workers.user_id', 'users.id') - ); - break; - case 'name_down': - $resumes = $resumes->orderByDesc(User::select('surname') - ->whereColumn('workers.user_id', 'users.id') - ); - break; - case 'created_at_up': - $resumes = $resumes->OrderBy('created_at')->orderBy('id'); - break; - case 'created_at_down': - $resumes = $resumes->orderByDesc('created_at')->orderBy('id'); + case 'looking_for_work': + $resumes->where('status_work', '=', WorkerStatuses::LookingForWork->value); break; - case 'default': - $resumes = $resumes->orderBy('id')->orderby('updated_at'); + case 'considering_offers': + $resumes->where('status_work', '=', WorkerStatuses::ConsideringOffers->value); break; - default: - $resumes = $resumes->orderBy('id')->orderby('updated_at'); + case 'not_looking_for_work': + $resumes->where('status_work', '=', WorkerStatuses::NotLookingForWork->value); break; } } @@ -208,7 +194,7 @@ class WorkerController extends Controller $idiot = 0; } - $status_work = $this->status_work; + $status_work = WorkerStatuses::getWorkerStatuses(); $Query = Worker::query()->with('users')->with('job_titles') ->with('place_worker')->with('sertificate')->with('prev_company') ->with('infobloks')->with('response'); @@ -245,7 +231,7 @@ class WorkerController extends Controller // скачать анкету соискателя public function resume_download(Worker $worker) { - $status_work = $this->status_work; + $status_work = WorkerStatuses::getWorkerStatuses(); $Query = Worker::query()->with('users')->with('job_titles') ->with('place_worker')->with('sertificate')->with('prev_company') ->with('infobloks'); @@ -254,7 +240,7 @@ class WorkerController extends Controller view()->share('Query',$Query); - $status_work = $this->status_work; + $status_work = WorkerStatuses::getWorkerStatuses(); $infoblocks = infobloks::query()->get(); //return view('layout.pdf', compact('Query', 'status_work', 'infoblocks')); @@ -390,7 +376,7 @@ class WorkerController extends Controller $persent5 = 5; } - $status_work = $this->status_work; + $status_work = WorkerStatuses::getWorkerStatuses(); $additional_document_statuses = [0 => 'Не указано', 1 => 'В наличии', 2 => 'Отсутствует']; $info_blocks = infobloks::query()->OrderBy('name')->get(); diff --git a/resources/views/employers/favorite.blade.php b/resources/views/employers/favorite.blade.php index 4693186..f20a555 100644 --- a/resources/views/employers/favorite.blade.php +++ b/resources/views/employers/favorite.blade.php @@ -149,10 +149,10 @@
- @if ($it->status_work == 0) Ищу работу - @elseif ($it->status_work == 1) Не указано - @elseif ($it->status_work == 2) Не ищу работу - @endif + @php + $worker_statuses = App\Enums\WorkerStatuses::getWorkerStatuses(); + @endphp + {{ $worker_statuses[$it->status_work] }}
Обновлено: {{ date('d.m.Y', strtotime($it->updated_at)) }} diff --git a/resources/views/info_company_new.blade.php b/resources/views/info_company_new.blade.php index c8d5042..18f3524 100644 --- a/resources/views/info_company_new.blade.php +++ b/resources/views/info_company_new.blade.php @@ -120,9 +120,10 @@ Написать сообщение @else - + @endif
diff --git a/resources/views/layout/pdf-list-people.blade.php b/resources/views/layout/pdf-list-people.blade.php index af01698..70c754e 100644 --- a/resources/views/layout/pdf-list-people.blade.php +++ b/resources/views/layout/pdf-list-people.blade.php @@ -246,8 +246,12 @@ Статус: - @php $code = $Q['status_work']; @endphp - @if ($code == 0) Ищу работу @elseif($code == 1) Не указано @else Не ищу работу @endif + @php + $worker_statuses = App\Enums\WorkerStatuses::getWorkerStatuses(); + $code = $Q['status_work']; + @endphp + {{ $worker_statuses[$code] }} + Город проживания: diff --git a/resources/views/resume.blade.php b/resources/views/resume.blade.php index d620c3b..aae36bb 100644 --- a/resources/views/resume.blade.php +++ b/resources/views/resume.blade.php @@ -240,11 +240,10 @@
diff --git a/resources/views/workers/form_basic_information.blade.php b/resources/views/workers/form_basic_information.blade.php index b654f83..df35f75 100644 --- a/resources/views/workers/form_basic_information.blade.php +++ b/resources/views/workers/form_basic_information.blade.php @@ -47,9 +47,9 @@
-- 1.7.10.4