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') +
+ + @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 @@