From a9dfa8c954400fe8212908cda8f39fbc6143f32b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=20=D0=9B=D0=B0=D1=80?= =?UTF-8?q?=D0=B8=D0=BE=D0=BD=D0=BE=D0=B2?= Date: Thu, 7 Mar 2024 15:33:44 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0?= =?UTF-8?q?=B8=D0=B5=20=D0=BD=D0=B0=207=20=D0=BC=D0=B0=D1=80=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Classes/StatusUser.php | 17 +++ app/Http/Controllers/CompanyController.php | 7 +- app/Http/Controllers/MainController.php | 54 ++++++- app/Http/Controllers/WorkerController.php | 58 +++++++ app/Http/Requests/DocumentsRequest.php | 47 ++++++ app/Models/place_works.php | 12 ++ app/Providers/MyServiceProvider.php | 6 +- resources/views/ajax/companies.blade.php | 8 +- resources/views/ajax/companies2.blade.php | 6 +- resources/views/ajax/education.blade.php | 25 +++ resources/views/companies.blade.php | 14 +- resources/views/education.blade.php | 41 ++--- resources/views/index.blade.php | 160 +------------------- resources/views/info_company.blade.php | 19 ++- resources/views/js/modals.blade.php | 154 +++++++++++++++++++ resources/views/layout/frontend.blade.php | 50 ++---- resources/views/list_vacancies.blade.php | 95 ++++++++++-- resources/views/modals/delete_profile.blade.php | 10 ++ resources/views/modals/send_employer.blade.php | 6 +- .../views/modals/send_message_noaut.blade.php | 4 +- resources/views/modals/send_worker.blade.php | 64 ++++++-- .../views/modals/success_delete_profile.blade.php | 7 + .../modals/thank_you_send_for_employer.blade.php | 9 ++ .../modals/thank_you_send_for_worker.blade.php | 7 + resources/views/workers/cabinet.blade.php | 14 +- resources/views/workers/docs-edit.blade.php | 101 ++++++++++++ resources/views/workers/docs.blade.php | 102 +++++++++++++ resources/views/workers/dop_info.blade.php | 1 - routes/web.php | 12 +- 29 files changed, 839 insertions(+), 271 deletions(-) create mode 100644 app/Classes/StatusUser.php create mode 100644 app/Http/Requests/DocumentsRequest.php create mode 100644 resources/views/ajax/education.blade.php create mode 100644 resources/views/js/modals.blade.php create mode 100644 resources/views/modals/delete_profile.blade.php create mode 100644 resources/views/modals/success_delete_profile.blade.php create mode 100644 resources/views/modals/thank_you_send_for_employer.blade.php create mode 100644 resources/views/modals/thank_you_send_for_worker.blade.php create mode 100644 resources/views/workers/docs-edit.blade.php create mode 100644 resources/views/workers/docs.blade.php diff --git a/app/Classes/StatusUser.php b/app/Classes/StatusUser.php new file mode 100644 index 0000000..b93d915 --- /dev/null +++ b/app/Classes/StatusUser.php @@ -0,0 +1,17 @@ +user()->id)) { + $is_worker = Auth()->user()->is_worker; + return $is_worker; + } else { + return false; + } + } +} diff --git a/app/Http/Controllers/CompanyController.php b/app/Http/Controllers/CompanyController.php index d6aa133..ebdd0a0 100644 --- a/app/Http/Controllers/CompanyController.php +++ b/app/Http/Controllers/CompanyController.php @@ -9,7 +9,7 @@ class CompanyController extends Controller { public function shipping_companies(Request $request) { $emps = Employer::query()->with('ads'); - if ($request->get('search')) { + if (($request->has('search')) && (!empty($request->get('search')))) { $search = $request->get('search'); $emps = $emps->where('name_company', 'LIKE', "%$search%"); } @@ -41,9 +41,10 @@ class CompanyController extends Controller } public function info_company(Employer $company) { - $company = Employer::with('ads')->with('flots') + $user_id = Auth()->user()->id; + $company = Employer::with('ads')->with('flots')->with('users') ->where('id', '=', $company->id)->get(); $title = $company[0]->name_company; - return view('info_company', compact('company', 'title')); + return view('info_company', compact('company', 'user_id', 'title')); } } diff --git a/app/Http/Controllers/MainController.php b/app/Http/Controllers/MainController.php index 2697920..2c30253 100644 --- a/app/Http/Controllers/MainController.php +++ b/app/Http/Controllers/MainController.php @@ -12,6 +12,7 @@ use App\Models\reclame; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Validator; +use App\Classes\StatusUser; class MainController extends Controller { @@ -70,24 +71,42 @@ class MainController extends Controller //Вакансии категория детальная public function list_vacancies(Category $categories, Request $request) { + if (isset(Auth()->user()->id)) + $uid = Auth()->user()->id; + else + $uid = 0; $Query = Ad_employer::with('jobs')-> with('cat')-> with('employer')-> whereHas('jobs_code', function ($query) use ($request) { if ($request->ajax()) { - if (null !== ($request->get('job'))) { + if (null !== ($request->get('job')) && ($request->get('job') !== 0)) { $query->where('job_title_id', $request->get('job')); } } }) ->select('ad_employers.*'); + + if ($categories->id > 0) { $Query = $Query->where('category_id', '=', $categories->id); $Name_categori = Category::query()->where('id', '=', $categories->id)->get(); } + if ($request->get('sort')) { + $sort = $request->get('sort'); + switch ($sort) { + case 'name_up': $Query = $Query->orderBy('name')->orderBy('id'); break; + case 'name_down': $Query = $Query->orderByDesc('name')->orderby('id'); break; + case 'created_at_up': $Query = $Query->OrderBy('created_at')->orderBy('id'); break; + case 'created_at_down': $Query = $Query->orderByDesc('created_at')->orderBy('id'); break; + case 'default': $Query = $Query->orderBy('id')->orderby('updated_at'); break; + default: $Query = $Query->orderBy('id')->orderby('updated_at'); break; + } + } + $Job_title = Job_title::query()->OrderBy('name')->get(); $Query_count = $Query->count(); @@ -99,7 +118,12 @@ class MainController extends Controller if ($request->ajax()) { - return view('ajax.list_vacancies', compact('Query', 'Query_count', 'Name_categori', 'Reclama', 'categories')); + return view('ajax.list_vacancies', compact('Query', + 'Query_count', + 'Name_categori', + 'Reclama', + 'categories', + 'uid')); } else { //Вернуть все return view('list_vacancies', compact('Query', @@ -107,20 +131,38 @@ class MainController extends Controller 'Reclama', 'Name_categori', 'categories', - 'Job_title')); + 'Job_title', + 'uid')); } } // Образование public function education(Request $request) { $educations = Education::query(); - if ($request->has('search')) { - $search = trim($request->has('search')); + if (($request->has('search')) && (!empty($request->get('search')))) { + $search = trim($request->get('search')); $educations = $educations->where('name', 'LIKE', "%$search%"); } + + if ($request->get('sort')) { + $sort = $request->get('sort'); + switch ($sort) { + case 'name_up': $educations = $educations->orderBy('name')->orderBy('id'); break; + case 'name_down': $educations = $educations->orderByDesc('name')->orderby('id'); break; + case 'created_at_up': $educations = $educations->OrderBy('created_at')->orderBy('id'); break; + case 'created_at_down': $educations = $educations->orderByDesc('created_at')->orderBy('id'); break; + case 'default': $educations = $educations->orderBy('id')->orderby('updated_at'); break; + default: $educations = $educations->orderBy('id')->orderby('updated_at'); break; + } + } + $count_edu = $educations->count(); $educations = $educations->paginate(6); - return view('education', compact('educations', 'count_edu')); + if ($request->ajax()) { + return view('ajax.education', compact('educations')); + } else { + return view('education', compact('educations', 'count_edu')); + } } // Контакты diff --git a/app/Http/Controllers/WorkerController.php b/app/Http/Controllers/WorkerController.php index c5c97f5..08b8255 100644 --- a/app/Http/Controllers/WorkerController.php +++ b/app/Http/Controllers/WorkerController.php @@ -3,13 +3,16 @@ namespace App\Http\Controllers; use App\Classes\RusDate; +use App\Http\Requests\DocumentsRequest; use App\Models\Ad_employer; +use App\Models\ad_response; use App\Models\Category; use App\Models\Dop_info; use App\Models\Employer; use App\Models\infobloks; use App\Models\Job_title; use App\Models\Message; +use App\Models\place_works; use App\Models\reclame; use App\Models\sertification; use App\Models\Static_worker; @@ -492,5 +495,60 @@ class WorkerController extends Controller if ($count == 0) $dop_info = Dop_info::create($params); return redirect()->route('worker.cabinet'); } + + // Добавление стандартного документа + public function add_document(Worker $worker) { + return view('workers.docs', compact('worker')); + } + + //Сохранение стандартого документа + public function add_document_save(DocumentsRequest $request) { + $params = $request->all(); + $place_work = place_works::create($params); + return redirect()->route('worker.cabinet')->with('success', 'Вы успешно добавили запись!'); + } + + // Редактирование документа + public function edit_document(place_works $doc, Worker $worker) { + return view('workers.docs-edit', compact('doc', 'worker')); + } + + //Сохранение отредактированного документа + public function edit_document_save(DocumentsRequest $request, place_works $doc) { + $params = $request->all(); + $doc->update($params); + + return redirect()->route('worker.cabinet')->with('success', 'Вы успешно отредактировали запись!'); + } + + // Удаление документа + public function delete_document(place_works $doc) { + $doc->delete(); + return redirect()->route('worker.cabinet')->with('success', 'Вы успешно удалили запись!'); + } + + //Отправка нового сообщения + public function new_message(Request $request) { + $params = $request->all(); + + $id = $params['send_user_id']; + $message = new Message(); + $message->user_id = $params['send_user_id']; + $message->to_user_id = $params['send_to_user_id']; + $message->title = $params['send_title']; + $message->text = $params['send_text']; + if ($request->has('send_file')) { + $message->file = $request->file('send_file')->store("worker/$id", 'public'); + } + $message->flag_new = 1; + $id_message = $message->save(); + + $data['message_id'] = $id_message; + $data['ad_employer_id'] = $params['send_vacancy']; + $data['job_title_id'] = $params['send_job_title_id']; + $data['flag'] = 1; + $ad_responce = ad_response::create($data); + return redirect()->route('worker.messages', ['type_message' => 'output']); + } } diff --git a/app/Http/Requests/DocumentsRequest.php b/app/Http/Requests/DocumentsRequest.php new file mode 100644 index 0000000..a557d59 --- /dev/null +++ b/app/Http/Requests/DocumentsRequest.php @@ -0,0 +1,47 @@ + + */ + public function rules() + { + return [ + 'job_title' => ['required', 'string', 'max:255'], + 'teplohod' => ['required', 'string', 'max:255'], + 'name_company' => ['required', 'string', 'max:255'], + ]; + } + + public function messages() { + return [ + 'required' => 'Укажите обязательное поле «:attribute»', + 'min' => [ + 'string' => 'Поле «:attribute» должно быть не меньше :min символов', + 'integer' => 'Поле «:attribute» должно быть :min или больше', + 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' + ], + 'max' => [ + 'string' => 'Поле «:attribute» должно быть не больше :max символов', + 'integer' => 'Поле «:attribute» должно быть :max или меньше', + 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' + ]]; + } +} diff --git a/app/Models/place_works.php b/app/Models/place_works.php index 8c005ed..6ec5e17 100644 --- a/app/Models/place_works.php +++ b/app/Models/place_works.php @@ -8,4 +8,16 @@ use Illuminate\Database\Eloquent\Model; class place_works extends Model { use HasFactory; + + public $fillable = [ + 'job_title', + 'tanker', + 'teplohod', + 'GWT', + 'KBT', + 'Begin_work', + 'End_work', + 'name_company', + 'worker_id' + ]; } diff --git a/app/Providers/MyServiceProvider.php b/app/Providers/MyServiceProvider.php index 6439f42..a8f1474 100644 --- a/app/Providers/MyServiceProvider.php +++ b/app/Providers/MyServiceProvider.php @@ -76,14 +76,14 @@ class MyServiceProvider extends ServiceProvider } ); - $views3 = ['layout.frontend']; + $views3 = ['layout.frontend', 'index']; View::composer($views3, function($view){ $id = Auth::user(); $companies = Company::query()->limit(1)->get(); - - $view->with(['UserId' => $id, 'companies' => $companies]); + $jobs = Job_title::query()->get(); + $view->with(['UserId' => $id, 'companies' => $companies, 'jobs' => $jobs]); } ); diff --git a/resources/views/ajax/companies.blade.php b/resources/views/ajax/companies.blade.php index eecb1f4..c281003 100644 --- a/resources/views/ajax/companies.blade.php +++ b/resources/views/ajax/companies.blade.php @@ -3,8 +3,12 @@ @foreach($emps as $emp)
- {{ $emp->name_company }} - + @if (!empty($emp->logo)) + {{ $emp->name_company }} + @else + {{ $emp->name_company }} + @endif + {{ $emp->name_company }} {{ $emp->ads->count() }} вакансия(ий) diff --git a/resources/views/ajax/companies2.blade.php b/resources/views/ajax/companies2.blade.php index c0f36a9..808b05d 100644 --- a/resources/views/ajax/companies2.blade.php +++ b/resources/views/ajax/companies2.blade.php @@ -3,7 +3,11 @@ @foreach($emps as $emp)
- {{ $emp->name_company }} + @if (!empty($emp->logo)) + {{ $emp->name_company }} + @else + {{ $emp->name_company }} + @endif {{ $emp->name_company }} {{ $emp->ads->count() }} вакансия(ий) diff --git a/resources/views/ajax/education.blade.php b/resources/views/ajax/education.blade.php new file mode 100644 index 0000000..aa0f3a5 --- /dev/null +++ b/resources/views/ajax/education.blade.php @@ -0,0 +1,25 @@ +
+ @if ($educations->count()) + @foreach($educations as $edu) +
+
+ {{ $edu->name }} + + + + + +
+
+ {{ $edu->name }} + {{ $edu->program_education->count() }} учебных направлений + Читать далее +
+
+ @endforeach + + {{ $educations->appends($_GET)->links('paginate') }} + @else +

Нет данных

+ @endif +
diff --git a/resources/views/companies.blade.php b/resources/views/companies.blade.php index d65ed74..751b976 100644 --- a/resources/views/companies.blade.php +++ b/resources/views/companies.blade.php @@ -78,7 +78,7 @@

С другой стороны, социально-экономическое развитие не оставляет шанса для существующих финансовых и административных условий.

- @if ($educations->count()) -
+ + +
+ @if ($educations->count()) @foreach($educations as $edu)
@@ -123,11 +109,12 @@
@endforeach + {{ $educations->appends($_GET)->links('paginate') }} + @else +

Нет данных

+ @endif
- {{ $educations->appends($_GET)->links('paginate') }} - @else -

Нет данных

- @endif + @@ -311,5 +291,7 @@ }; @yield('scripts') + +@include('js.modals') diff --git a/resources/views/list_vacancies.blade.php b/resources/views/list_vacancies.blade.php index 72b360a..7d33a07 100644 --- a/resources/views/list_vacancies.blade.php +++ b/resources/views/list_vacancies.blade.php @@ -1,3 +1,7 @@ +@php + use App\Classes\StatusUser; +@endphp + @extends('layout.frontend', ['title' => 'Вакансии РекаМоре']) @section('scripts') @@ -17,6 +21,7 @@ console.log('Выбор сделан!'); console.log(data); main_oskar.html(data); + history.pushState({}, '', "{{ route('education') }}?sort="+val_+"@if (isset($_GET['page']))&page={{ $_GET['page'] }}@endif"); }, headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') @@ -27,13 +32,75 @@ } }); }); + + $(document).on('click', '.js_send_it_button', function() { + var this_ = $(this); + var code_user_id = this_.attr('data-uid'); + var code_to_user_id = this_.attr('data-tuid'); + var code_vacancy = this_.attr('data-vacancy'); + var user_id = $('#send_user_id'); + var to_user_id = $('#send_to_user_id'); + var vacancy = $('#send_vacancy'); + + console.log('Клик на кнопки...'); + + user_id.val(code_user_id); + to_user_id.val(code_to_user_id); + vacancy.val(code_vacancy); + }); + + $(document).on('change', '#sort_ajax', function() { + var this_ = $(this); + var val_ = this_.val(); + console.log('sort items '+val_); + + $.ajax({ + type: "GET", + url: "{{ route('list-vacancies', ['categories' => $categories->id]) }}", + data: "sort="+val_+"&block=1", + success: function (data) { + console.log('Выбор сортировки'); + console.log(data); + $('#main_ockar').html(data); + history.pushState({}, '', "{{ route('list-vacancies', ['categories' => $categories->id]) }}?sort="+val_+"@if (isset($_GET['page']))&page={{ $_GET['page'] }}@endif"); + }, + headers: { + 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') + }, + error: function (data) { + data = JSON.stringify(data); + console.log('Error: ' + data); + } + }); + }); + + + + $(document).ready(function(){ + var sel = $('#select2-sort_ajax-container'); + var key = getUrlParameter('sort'); + console.log(sel); + console.log(key); + + if (key !=='') { + console.log(key); + switch (key) { + case "default": sel.html('Сортировка (по умолчанию)'); break; + case "name_up": sel.html('По имени (возрастание)'); break; + case "name_down": sel.html('По дате (убывание)'); break; + case "created_at_up": sel.html('По дате (возрастание)'); break; + case "created_at_down": sel.html('По дате (убывание)'); break; + } + + } + }); @include('js.favorite-vacancy') @endsection @section('content')
-
+
- - - - + + + +
+
@foreach ($Query as $Q)
@@ -142,8 +210,18 @@ @endif
- + @guest + + @else + @if (App\Classes\StatusUser::Status()==1) + + @else + + @endif + @endguest Подробнее
@@ -159,7 +237,6 @@
{{ $Query->appends($_GET)->links('paginate') }}
-
diff --git a/resources/views/modals/delete_profile.blade.php b/resources/views/modals/delete_profile.blade.php new file mode 100644 index 0000000..f9a9d5c --- /dev/null +++ b/resources/views/modals/delete_profile.blade.php @@ -0,0 +1,10 @@ + diff --git a/resources/views/modals/send_employer.blade.php b/resources/views/modals/send_employer.blade.php index 7a54922..5c0f567 100644 --- a/resources/views/modals/send_employer.blade.php +++ b/resources/views/modals/send_employer.blade.php @@ -1,7 +1,7 @@ -