From 2be890eeabec2f0588251c3db155dd44d6427a09 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: Tue, 16 Apr 2024 19:31:50 +0700 Subject: [PATCH] =?UTF-8?q?=D0=BA=D0=BE=D0=BC=D0=BC=D0=B8=D1=82=20=D0=BF=D0=BE?= =?UTF-8?q?=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F=D0=BC=20?= =?UTF-8?q?=D1=81=D1=82=D1=80=D1=83=D0=BA=D1=82=D1=83=D1=80=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Admin/AdminController.php | 8 +- app/Http/Controllers/EmployerController.php | 31 +++- app/Http/Controllers/MainController.php | 58 +++++-- app/Http/Controllers/WorkerController.php | 6 +- app/Http/Requests/RequestAdminNews.php | 5 +- resources/views/admin/news/edit.blade.php | 121 +++++++++++++- resources/views/admin/news/form.blade.php | 9 +- resources/views/ajax/new_sky.blade.php | 4 +- resources/views/block_real_new.blade.php | 31 ++++ .../views/employers/add_vacancy-first.blade.php | 170 ++++++++++++++++++++ resources/views/employers/add_vacancy.blade.php | 142 +++++++++++++++- .../views/employers/ajax/list_vacancy.blade.php | 31 +++- resources/views/index.blade.php | 9 +- resources/views/list_vacancies.blade.php | 2 +- resources/views/new_sky.blade.php | 9 +- resources/views/worker.blade.php | 2 +- 16 files changed, 581 insertions(+), 57 deletions(-) create mode 100644 resources/views/block_real_new.blade.php create mode 100644 resources/views/employers/add_vacancy-first.blade.php diff --git a/app/Http/Controllers/Admin/AdminController.php b/app/Http/Controllers/Admin/AdminController.php index cee6877..92252fe 100644 --- a/app/Http/Controllers/Admin/AdminController.php +++ b/app/Http/Controllers/Admin/AdminController.php @@ -407,16 +407,14 @@ class AdminController extends Controller public function new_admin_update_save(RequestAdminNews $request, News $new) { $params = $request->all(); + if ($request->has('image')) { - if (!empty($request->get('image'))) { $params['image'] = $request->file('image')->store('news', 'public'); - } else { + } else { if (!empty($new->image)) $params['image'] = $new->image; - else - unset($params['image']); - } } + $new->update($params); return redirect()->route('admin.news_admin'); } diff --git a/app/Http/Controllers/EmployerController.php b/app/Http/Controllers/EmployerController.php index 8438263..782b8f3 100644 --- a/app/Http/Controllers/EmployerController.php +++ b/app/Http/Controllers/EmployerController.php @@ -127,9 +127,9 @@ class EmployerController extends Controller $categories = Category::query()->active()->get(); $Positions = Category::query()->active()->get(); if ($Positions->count()) { - $jobs = Job_title::query()->OrderBy('name')->where('position_id', $Positions[0]->id)->get(); + $jobs = Job_title::query()->OrderBy('name')->Notbdif()->where('position_id', $Positions[0]->id)->get(); } else { - $jobs = Job_title::query()->OrderBy('name')->where('position_id', 0)->get(); + $jobs = Job_title::query()->OrderBy('name')->Notbdif()->where('position_id', 0)->get(); } $Employer = Employer::query()->with('users')->with('ads')->with('flots')-> @@ -142,9 +142,20 @@ class EmployerController extends Controller // Сохранение вакансии public function cabinet_vacancy_save1(VacancyRequestEdit $request) { - $params = $request->all(); - - $ad_jobs = Ad_employer::create($params); + $params_emp = $request->all(); + $params_job["job_title_id"] = $params_emp['job_title_id']; + $params_job["min_salary"] = $params_emp['min_salary']; + $params_job["max_salary"] = $params_emp['max_salary']; + $params_job["region"] = $params_emp['region']; + $params_job["power"] = $params_emp['power']; + $params_job["sytki"] = $params_emp['sytki']; + $params_job["start"] = $params_emp['start']; + $params_job["flot"] = $params_emp['flot']; + $params_job["description"] = $params_emp['description']; + + $ad_jobs = Ad_employer::create($params_emp); + $params_job['ad_employer_id'] = $ad_jobs->id; + Ad_jobs::create($params_job); return redirect()->route('employer.vacancy_list'); } @@ -152,8 +163,9 @@ class EmployerController extends Controller public function vacancy_list(Request $request) { $id = Auth()->user()->id; $Employer = Employer::query()->where('user_id', $id)->first(); - $vacancy_list = Ad_employer::query()->with('jobs')->with('jobs_code')->where('employer_id', $Employer->id); - + $vacancy_list = Ad_employer::query()->with('jobs')-> + with('jobs_code')-> + where('employer_id', $Employer->id); if ($request->get('sort')) { $sort = $request->get('sort'); @@ -359,6 +371,11 @@ class EmployerController extends Controller ] ]; + $email = $request->get('email'); + if (!preg_match("/^[a-zA-Z0-9_\-.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-.]+$/", $email)) { + return json_encode(Array("ERROR" => "Error: Отсутствует емайл или некорректный емайл")); + } + if ($request->get('password') !== $request->get('confirmed')){ return json_encode(Array("ERROR" => "Error: Не совпадают пароль и подтверждение пароля")); } diff --git a/app/Http/Controllers/MainController.php b/app/Http/Controllers/MainController.php index 5b7abc9..4905419 100644 --- a/app/Http/Controllers/MainController.php +++ b/app/Http/Controllers/MainController.php @@ -40,7 +40,7 @@ class MainController extends Controller ->get(); $Position = Category::query()->where('is_remove', '=', '0')->get(); - + $job_titles = Job_title::query()->where('is_remove', '=', 0)->get(); /*$BigFlot = Array(); foreach ($Position as $position) { $BigFlot[] = DB::table('ad_jobs')->selectRaw('name, job_titles.id as id_title, count(`ad_jobs`.`id`) as cnt, ad_jobs.position_ship')-> @@ -50,11 +50,8 @@ class MainController extends Controller groupby('job_title_id','position_ship')-> get(); } - $BigFlot = Array(); - foreach ($Position as $position) { - $BigFlot[] = Ad_jobs::query()->with(['job_title' => function($query) { $query->OrderBy('sort'); }])->whereHas('job_title', function ($query) use ($position) { @@ -63,21 +60,35 @@ class MainController extends Controller distinct('job_title_id')-> get(); }*/ - - $BigFlot = Array(); + /*$BigFlot = Array(); foreach ($Position as $position) { - $BigFlot[] = DB::table('ad_jobs')-> - selectRaw('name, count(`ad_jobs`.`id`) as cnt, job_title_id, job_titles.name')-> + $BigFlot[$position->id] = DB::table('ad_jobs')-> + selectRaw('name, count(`ad_jobs`.`id`) as cnt, job_title_id, job_titles.name, job_titles.position_id')-> orderByDesc('job_titles.sort')-> join('job_titles', 'job_titles.id', '=', 'ad_jobs.job_title_id')-> where('job_titles.position_id', $position->id)-> groupby('job_title_id')-> get(); + }*/ + $Data = DB::table('job_titles')-> + selectRaw('job_titles.name as jn, count(`ad_jobs`.`job_title_id`) as cnt, job_titles.id as id_job, categories.name as catname, categories.id as id_cat')-> + leftJoin('ad_jobs', 'ad_jobs.job_title_id', '=', 'job_titles.id')-> + join('categories', 'categories.id', '=', 'job_titles.position_id')-> + groupBy('job_titles.id')->orderByDesc('job_titles.position_id')-> + orderByDesc('job_titles.sort')->get()->toArray(); + + $Main_Job = array(); + $name_cat = ''; + foreach ($Data as $it) { + $it_arr = (array)$it; + if ($name_cat != $it_arr['catname']) + $name_cat = $it_arr['catname']; + $Main_Job[$name_cat][] = $it_arr; } $employers = employers_main::query()->with('employer')->orderBy('id')->limit(8)->get(); $vacancy = Ad_jobs::query()->with('job_title')->orderBy('position_ship')->get(); - return view('index', compact('news', 'categories', 'employers', 'vacancy', 'BigFlot', 'Position')); + return view('index', compact('news', 'job_titles', 'categories', 'employers', 'vacancy', 'Main_Job')); } public function search_vacancies(Request $request) { @@ -132,7 +143,6 @@ class MainController extends Controller } } - public function vacancies(Request $request) { //должности $Job_title = Job_title::query()->orderBy('name')->get(); @@ -149,7 +159,7 @@ class MainController extends Controller $categories = $categories->OrderByDesc('created_at')->GroupBy('categories.id')->get(); - $Position = Category::query()->where('is_remove', '=', '0')->get(); + //$Position = Category::query()->where('is_remove', '=', '0')->get(); /*$BigFlot = Array(); foreach ($Position as $position) { @@ -163,7 +173,7 @@ class MainController extends Controller $War_flot = $War_flot->groupby('job_title_id','position_ship')->get(); $BigFlot[] = $War_flot; }*/ - + /* $BigFlot = Array(); foreach ($Position as $position) { $WarFlot = DB::table('ad_jobs')-> @@ -177,11 +187,31 @@ class MainController extends Controller $WarFlot = $WarFlot->groupby('job_title_id')->get(); $BigFlot[] = $WarFlot; } + */ + + $Data = DB::table('job_titles')-> + selectRaw('job_titles.name as jn, count(`ad_jobs`.`job_title_id`) as cnt, job_titles.id as id_job, categories.name as catname, categories.id as id_cat'); + if (($request->has('job')) && ($request->get('job') > 0)) { + $Data = $Data->where('job_title_id', $request->get('job')); + } + $Data = $Data->leftJoin('ad_jobs', 'ad_jobs.job_title_id', '=', 'job_titles.id')-> + join('categories', 'categories.id', '=', 'job_titles.position_id')-> + groupBy('job_titles.id')->orderByDesc('job_titles.position_id')-> + orderByDesc('job_titles.sort')->get()->toArray(); + + $Main_Job = array(); + $name_cat = ''; + foreach ($Data as $it) { + $it_arr = (array)$it; + if ($name_cat != $it_arr['catname']) + $name_cat = $it_arr['catname']; + $Main_Job[$name_cat][] = $it_arr; + } if ($request->ajax()) { - return view('ajax.new_sky', compact('categories', 'BigFlot', 'Position')); + return view('ajax.new_sky', compact('categories', 'Main_Job')); } else { - return view('new_sky', compact('Job_title', 'categories', 'BigFlot', 'Position')); + return view('new_sky', compact('Job_title', 'categories', 'Main_Job')); } } diff --git a/app/Http/Controllers/WorkerController.php b/app/Http/Controllers/WorkerController.php index 343f810..f4fa85f 100644 --- a/app/Http/Controllers/WorkerController.php +++ b/app/Http/Controllers/WorkerController.php @@ -344,8 +344,7 @@ class WorkerController extends Controller } $id_wor = $worker->update($params); - - $use = User_Model::find($id_wor); + $use = User::find($worker->user_id); $use->surname = $request->get('surname'); $use->name_man = $request->get('name_man'); $use->surname2 = $request->get('surname2'); @@ -488,7 +487,8 @@ class WorkerController extends Controller ] ]; - if (empty($request->get('email'))) { + $email = $request->get('email'); + if (!preg_match("/^[a-zA-Z0-9_\-.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-.]+$/", $email)) { return json_encode(Array("ERROR" => "Error: Отсутствует емайл или некорректный емайл")); } diff --git a/app/Http/Requests/RequestAdminNews.php b/app/Http/Requests/RequestAdminNews.php index a282e59..626bc98 100644 --- a/app/Http/Requests/RequestAdminNews.php +++ b/app/Http/Requests/RequestAdminNews.php @@ -44,9 +44,10 @@ class RequestAdminNews extends FormRequest 'min:3', 'max:255', ], - 'text' => [ + 'text' => [ 'required', - 'min:255', + 'min:50', + 'max:99999999' ], ]; return $Array1; diff --git a/resources/views/admin/news/edit.blade.php b/resources/views/admin/news/edit.blade.php index ac42c5b..3c1a2fb 100644 --- a/resources/views/admin/news/edit.blade.php +++ b/resources/views/admin/news/edit.blade.php @@ -1,8 +1,127 @@ @extends('layout.admin', ['title' => 'Админка - Редактирование новости']) @section('content') +
@csrf - @include('admin.news.form') + + +
+
+ +
+ +
+ +
+ +
+
+ + Назад +
+
+
+ + @endsection diff --git a/resources/views/admin/news/form.blade.php b/resources/views/admin/news/form.blade.php index 3a4f50e..2fc467e 100644 --- a/resources/views/admin/news/form.blade.php +++ b/resources/views/admin/news/form.blade.php @@ -46,7 +46,7 @@ Заголовой новости @error('title') @@ -59,7 +59,7 @@ Код в URL-строке @error('slug') @@ -71,7 +71,7 @@
diff --git a/resources/views/ajax/new_sky.blade.php b/resources/views/ajax/new_sky.blade.php index fd815ba..ad7f6ec 100644 --- a/resources/views/ajax/new_sky.blade.php +++ b/resources/views/ajax/new_sky.blade.php @@ -1,5 +1,5 @@ -@foreach ($BigFlot as $key => $flot) +@foreach($Main_Job as $key => $it_main)
- @include('block_real', ['flot' => $flot, 'position' => $Position[$key]]) + @include('block_real_new', ['it_main' => $it_main, 'category' => $key])
@endforeach diff --git a/resources/views/block_real_new.blade.php b/resources/views/block_real_new.blade.php new file mode 100644 index 0000000..80046da --- /dev/null +++ b/resources/views/block_real_new.blade.php @@ -0,0 +1,31 @@ +@php $colors = Array('#F4C4C2', '#FBF1C8', '#ECFDEF', '#F3ECF6', '#ECFDEF'); + $i = 0; + $k = 0; +@endphp +@if (count($it_main) > 0) + @foreach ($it_main as $cat) + @if ($k == 0) +
{{ $category }}
+ @endif + + + + {{ $cat['jn'] }} + Вакансий: {{ $cat['cnt'] }} + + + + @php + $i++; + $k++; + if ($i > 4) {$i = 0;} + @endphp + @endforeach +@else +
{{ $category }}
+ + + Тут нет информации + + +@endif diff --git a/resources/views/employers/add_vacancy-first.blade.php b/resources/views/employers/add_vacancy-first.blade.php new file mode 100644 index 0000000..b9f2e44 --- /dev/null +++ b/resources/views/employers/add_vacancy-first.blade.php @@ -0,0 +1,170 @@ +@extends('layout.frontend', ['title' => 'Добавление вакансии РекаМоре']) + +@section('scripts') + +@endsection +@section('content') +
+
+ +
+
+
+ + @include('employers.emblema') + +
+ + @include('employers.menu', ['item' => 2]) + +
+ +
+ @csrf + +
+
+

Разместить вакансию

+

Данные по вакансии

+

Все поля обязательны для заполнения *

+
+
+ +
+

Поля для вакансии

+
+
+ +
+ + @error('name') + + {{ $message }} + + @enderror +
+
+ +
+ +
+ + @error('telephone') + + {{ $message }} + + @enderror +
+
+ +
+ +
+ + @error('email') + + {{ $message }} + + @enderror +
+
+ + + + + +
+ +
+
+ + @error('category_id') + + {{ $message }} + + @enderror +
+
+
+ +
+ +
+ + @error('text') + + {{ $message }} + + @enderror +
+
+
+ +
+
+
+
+
+ +@endsection diff --git a/resources/views/employers/add_vacancy.blade.php b/resources/views/employers/add_vacancy.blade.php index b9f2e44..5507868 100644 --- a/resources/views/employers/add_vacancy.blade.php +++ b/resources/views/employers/add_vacancy.blade.php @@ -3,7 +3,7 @@ @section('scripts')