diff --git a/app/Classes/Capcha.php b/app/Classes/Capcha.php new file mode 100644 index 0000000..000085a --- /dev/null +++ b/app/Classes/Capcha.php @@ -0,0 +1,63 @@ +USE_SESSION = true; + // 1. Генерируем код капчи + // 1.1. Устанавливаем символы, из которых будет составляться код капчи + $this->chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz'; + // 1.2. Количество символов в капче + $this->length = 6; + } + + public function Release() { + // 1.3. Генерируем код + $code = substr(str_shuffle($this->chars), 0, $this->length); + + if ($this->USE_SESSION) { + // 2a. Используем сессию + session_start(); + $_SESSION['captcha'] = crypt($code, '$1$itchief$7'); + session_write_close(); + } else { + // 2a. Используем куки (время действия 600 секунд) + $value = crypt($code, '$1$itchief$7'); + $expires = time() + 600; + setcookie('captcha', $value, $expires, '/', 'test.ru', false, true); + } + + // 3. Генерируем изображение + // 3.1. Создаем новое изображение из файла + $image = imagecreatefrompng(__DIR__ . '/files/bg.png'); + // 3.2 Устанавливаем размер шрифта в пунктах + $size = 36; + // 3.3. Создаём цвет, который будет использоваться в изображении + $color = imagecolorallocate($image, 66, 182, 66); + // 3.4. Устанавливаем путь к шрифту + $font = __DIR__ . '/files//oswald.ttf'; + // 3.5 Задаём угол в градусах + $angle = rand(-10, 10); + // 3.6. Устанавливаем координаты точки для первого символа текста + $x = 56; + $y = 64; + // 3.7. Наносим текст на изображение + imagefttext($image, $size, $angle, $x, $y, $color, $font, $code); + // 3.8 Устанавливаем заголовки + header('Cache-Control: no-store, must-revalidate'); + header('Expires: 0'); + header('Content-Type: image/png'); + // 3.9. Выводим изображение + imagepng($image); + // 3.10. Удаляем изображение + imagedestroy($image); + } +} diff --git a/app/Http/Controllers/Admin/AdminController.php b/app/Http/Controllers/Admin/AdminController.php index a5d4c23..cee6877 100644 --- a/app/Http/Controllers/Admin/AdminController.php +++ b/app/Http/Controllers/Admin/AdminController.php @@ -5,9 +5,11 @@ namespace App\Http\Controllers\Admin; use App\Classes\Tools; use App\Http\Controllers\Controller; use App\Http\Requests\CompanyRequest; +use App\Http\Requests\RequestAdminNews; use App\Http\Requests\RequestPosition; use App\Models\Company; use App\Models\Employer; +use App\Models\News; use App\Models\Positions; use App\Models\User; use Carbon\Carbon; @@ -378,4 +380,50 @@ class AdminController extends Controller $position->delete(); return redirect()->route('admin.position'); } + + public function news_admin() { + $news = News::query()->paginate(10); + return view('admin.news.list', compact('news')); + } + + public function new_admin_add() { + return view('admin.news.add'); + } + + public function new_admin_add_save(RequestAdminNews $request) { + $params = $request->all(); + if ($request->has('image')) { + $params['image'] = $request->file('image')->store('news', 'public'); + } + + News::create($params); + return redirect()->route('admin.news_admin'); + } + + public function new_admin_edit(News $new) { + // Вернуть все + return view('admin.news.edit', compact('new')); + } + + 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 { + if (!empty($new->image)) + $params['image'] = $new->image; + else + unset($params['image']); + } + } + $new->update($params); + return redirect()->route('admin.news_admin'); + } + + public function new_admin_delete(News $new) + { + $new->delete(); + return redirect()->route('admin.news_admin'); + } } diff --git a/app/Http/Controllers/EmployerController.php b/app/Http/Controllers/EmployerController.php index 7219c2e..937803d 100644 --- a/app/Http/Controllers/EmployerController.php +++ b/app/Http/Controllers/EmployerController.php @@ -75,6 +75,15 @@ class EmployerController extends Controller return view('employers.cabinet45', compact('Employer')); } + public function slider_flot() { + $id = Auth()->user()->id; + $Employer = Employer::query()->with('users')->with('ads')->with('flots')-> + WhereHas('users', + function (Builder $query) use ($id) {$query->Where('id', $id); + })->get(); + return view('employers.fly-flot', compact('Employer')); + } + public function cabinet_save(Employer $Employer, Request $request) { $params = $request->all(); $params['user_id'] = Auth()->user()->id; @@ -101,14 +110,14 @@ class EmployerController extends Controller } Flot::create($params); $data_flots = Flot::query()->where('employer_id', $request->get('employer_if'))->get(); - return redirect()->route('employer.cabinet')->with('success', 'Новый корабль был добавлен'); + return redirect()->route('employer.slider_flot')->with('success', 'Новый корабль был добавлен'); } public function delete_flot(Flot $Flot) { $data_flots = Flot::query()->where('employer_id', $Flot->employer_id)->get(); if (isset($Flot->id)) $Flot->delete(); - return redirect()->route('employer.cabinet')->with('success', 'Корабль был удален'); + return redirect()->route('employer.slider_flot')->with('success', 'Корабль был удален'); } // Форма добавления вакансий @@ -329,8 +338,8 @@ class EmployerController extends Controller $params = $request->all(); $rules = [ - 'surname' => ['required', 'string', 'max:255'], - 'name_man' => ['required', 'string', 'max:255'], + //'surname' => ['required', 'string', 'max:255'], + //'name_man' => ['required', 'string', 'max:255'], 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], 'name_company' => ['required', 'string', 'max:255'], 'password' => ['required', 'string', 'min:8'], @@ -355,7 +364,15 @@ class EmployerController extends Controller return json_encode(Array("ERROR" => "Error: Не совпадают пароль и подтверждение пароля")); } - $validator = Validator::make($request->all(), $rules, $messages); + if (empty($request->get('surname'))) { + $params['surname'] = 'Неизвестно'; + } + + if (empty($request->get('name_man'))) { + $params['name_man'] = 'Неизвестно'; + } + + $validator = Validator::make($params, $rules, $messages); if ($validator->fails()) { return json_encode(Array("ERROR" => "Error1: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены. Либо вы уже были зарегистрированы в системе.")); @@ -500,10 +517,14 @@ class EmployerController extends Controller // ->whereColumn('locations.document_id', 'documents.id') //); + $users = User_Model::query()->with('workers'); - if (isset($request->find)) { - $find_key = $request->find; + + if ($request->has('search')) { + $find_key = $request->get('search'); $users = $users->where('name', 'LIKE', "%$find_key%") + ->orWhere('surname', 'LIKE', "%$find_key%") + ->orWhere('name_man', 'LIKE', "%$find_key%") ->orWhere('email', 'LIKE', "%$find_key%") ->orWhere('telephone', 'LIKE', "%$find_key%"); } @@ -513,6 +534,7 @@ class EmployerController extends Controller orderBy(Worker::select('position_work')->whereColumn('Workers.user_id', 'users.id'))-> paginate(5); + return view('employers.bd', compact('users')); } diff --git a/app/Http/Controllers/MainController.php b/app/Http/Controllers/MainController.php index 29d3c7c..411d19a 100644 --- a/app/Http/Controllers/MainController.php +++ b/app/Http/Controllers/MainController.php @@ -193,16 +193,20 @@ class MainController extends Controller else $uid = 0; + if ($request->get('job') == 0) + $job_search = ''; + else + $job_search = $request->get('job'); + $Query = Ad_employer::with('jobs')-> with('cat')-> with('employer')-> - whereHas('jobs_code', function ($query) use ($request) { - if (null !== ($request->get('job')) && ($request->get('job') !== 0)) { - $query->where('job_title_id', $request->get('job')); - } - }) - ->select('ad_employers.*'); + whereHas('jobs_code', function ($query) use ($job_search) { + if (!empty($job_search)) { + $query->where('job_title_id', $job_search); + } + })->select('ad_employers.*'); if (isset($categories->id) && ($categories->id > 0)) { $Query = $Query->where('category_id', '=', $categories->id); @@ -213,8 +217,6 @@ class MainController extends Controller 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; @@ -233,8 +235,6 @@ class MainController extends Controller $Reclama = reclame::query()->get(); - - if ($request->ajax()) { if ($request->has('title')) { return view('ajax.list_category', compact( @@ -323,7 +323,8 @@ class MainController extends Controller if ($validator->fails()) { - return redirect()->route('index')->with('Error', "Email или пароль невалидный"); + return json_encode(Array("ERROR" => "Email или пароль невалидный!")); + //redirect()->route('index')->with('Error', "Email или пароль невалидный"); } else { $credentials = $request->only('email', 'password'); diff --git a/app/Http/Controllers/WorkerController.php b/app/Http/Controllers/WorkerController.php index 1b0d34c..0a994f4 100644 --- a/app/Http/Controllers/WorkerController.php +++ b/app/Http/Controllers/WorkerController.php @@ -75,6 +75,8 @@ class WorkerController extends Controller $idiot = 0; } + + $status_work = $this->status_work; $resumes = Worker::query()->with('users')->with('job_titles'); $resumes = $resumes->whereHas('users', function (Builder $query) { @@ -82,6 +84,15 @@ class WorkerController extends Controller ->Where('is_bd', '=', '0'); }); + //dd($request->get('job')); + if (($request->has('job')) && ($request->get('job') > 0)) { + $resumes = $resumes->whereHas('job_titles', function(Builder $query) use ($request) { + $query->Where('job_titles.id', $request->get('job')); + }); + } + + $Job_title = Job_title::query()->get(); + if ($request->get('sort')) { $sort = $request->get('sort'); switch ($sort) { @@ -103,6 +114,8 @@ class WorkerController extends Controller } $res_count = $resumes->count(); + //$resumes = $resumes->get(); + $resumes = $resumes->paginate(4); if ($request->ajax()) { // Условия обставлены @@ -114,7 +127,7 @@ class WorkerController extends Controller return view('ajax.resume_2', compact('resumes', 'status_work', 'res_count', 'idiot')); } } else { - return view('resume', compact('resumes', 'status_work', 'res_count', 'idiot')); + return view('resume', compact('resumes', 'status_work', 'res_count', 'idiot', 'Job_title')); } } @@ -180,6 +193,21 @@ class WorkerController extends Controller return $pdf->stream(); } + public function resume_download_all() { + $status_work = $this->status_work; + $Query = Worker::query()->with('users')->with('job_titles') + ->with('place_worker')->with('sertificate')->with('prev_company') + ->with('infobloks'); + //$Query = $Query->where('id', '=', $worker->id); + $Query = $Query->get()->toArray(); + + view()->share('Query',$Query); + + $pdf = PDF::loadView('layout.pdf-list-people', $Query); //->setPaper('a4', 'landscape'); + + return $pdf->stream(); + } + // Кабинет работника public function cabinet(Request $request) { @@ -464,11 +492,12 @@ class WorkerController extends Controller } if (($request->has('politik')) && ($request->get('politik') == 1)) { - $validator = Validator::make($request->all(), $rules, $messages); + $validator = Validator::make($params, $rules, $messages); if ($validator->fails()) { return json_encode(array("ERROR" => "Error1: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены. Либо вы уже были зарегистрированы в системе.")); } else { + $user = $this->create($params); event(new Registered($user)); Auth::guard()->login($user); @@ -522,7 +551,8 @@ class WorkerController extends Controller 'telephone' => $data['telephone'], 'password' => Hash::make($data['password']), 'pubpassword' => base64_encode($data['password']), - 'email_verified_at' => Carbon::now() + 'email_verified_at' => Carbon::now(), + 'is_worker' => $data['is_worker'], ]); if ($Code_user->id > 0) { $Worker = new Worker(); @@ -626,17 +656,29 @@ class WorkerController extends Controller return redirect()->route('worker.cabinet')->with('success', 'Ваша анкета была поднята выше остальных'); } + // Форма сертификате + public function new_sertificate(Worker $worker) { + return view('workers.sertificate_add', compact('worker')); + } + // Добавление сертификата public function add_serificate(Request $request) { $params = $request->all(); - $params['date_begin'] = date('d.m.Y', strtotime($params['date_begin'])); - $params['end_begin'] = date('d.m.Y', strtotime($params['end_begin'])); + $Sertificate = new sertification(); $Sertificate->create($params); $Docs = sertification::query()->where('worker_id', $request->get('worker_id'))->get(); - return view('ajax.documents', compact('Docs')); + return redirect()->route('worker.cabinet'); + //return view('ajax.documents', compact('Docs')); } + public function delete_diplom(Request $request, Worker $worker) { + $infoblok_id = $request->get('infoblok_id'); + $id = Dop_info::query()->where('worker_id', $worker->id)->where('infoblok_id', $infoblok_id)->delete(); + + //$Infoblocks = infobloks::query()->get(); + return redirect()->route('worker.cabinet')->getTargetUrl(); //view('workers.ajax.diploms_dop', compact('worker', 'Infoblocks')); + } // Удалить сертификат public function delete_sertificate(sertification $doc) { diff --git a/app/Http/Requests/RequestAdminNews.php b/app/Http/Requests/RequestAdminNews.php new file mode 100644 index 0000000..e9fa7dd --- /dev/null +++ b/app/Http/Requests/RequestAdminNews.php @@ -0,0 +1,30 @@ + + */ + public function rules() + { + return [ + // + ]; + } +} diff --git a/app/Models/User.php b/app/Models/User.php index 949eb51..3705ebb 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -31,6 +31,7 @@ class User extends Authenticatable 'is_lookin', 'is_message', 'is_public', + 'is_worker', 'is_remove', 'is_ban', 'is_new', diff --git a/resources/views/admin/news/add.blade.php b/resources/views/admin/news/add.blade.php new file mode 100644 index 0000000..2c29008 --- /dev/null +++ b/resources/views/admin/news/add.blade.php @@ -0,0 +1,8 @@ +@extends('layout.admin', ['title' => 'Админка - Добавление новости']) + +@section('content') +
+@endsection diff --git a/resources/views/admin/news/edit.blade.php b/resources/views/admin/news/edit.blade.php new file mode 100644 index 0000000..ac42c5b --- /dev/null +++ b/resources/views/admin/news/edit.blade.php @@ -0,0 +1,8 @@ +@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 new file mode 100644 index 0000000..e6b5b2b --- /dev/null +++ b/resources/views/admin/news/form.blade.php @@ -0,0 +1,77 @@ + + + + diff --git a/resources/views/admin/news/list.blade.php b/resources/views/admin/news/list.blade.php new file mode 100644 index 0000000..52ff010 --- /dev/null +++ b/resources/views/admin/news/list.blade.php @@ -0,0 +1,92 @@ +@extends('layout.admin', ['title' => 'Админка - Реклама сайта']) + +@section('script') + + +@endsection + +@section('modal') + @include('admin.reclames.modal') +@endsection + +@section('search') + +@endsection + +@section('content') + + + Добавить новость + +№ | +Заголовок новости | +Дата публикации/редактирования | +Редактировать | +
---|---|---|---|
+ {{$new->id}} + | ++ {{$new->title}} + | + ++ {{ $new->created_at }} / {{ $new->updated_at }} + | ++ Изменить | + Удалить + | +
По данному запросу ничего не найдено
@endif diff --git a/resources/views/ajax/resume_2.blade.php b/resources/views/ajax/resume_2.blade.php index 8160b7f..4f8074d 100644 --- a/resources/views/ajax/resume_2.blade.php +++ b/resources/views/ajax/resume_2.blade.php @@ -42,10 +42,21 @@ + Перейти в резюме @endforeach {{ $resumes->appends($_GET)->links('paginate') }} +@else +По данному запросу ничего не найдено
@endif diff --git a/resources/views/employers/add_vacancy.blade.php b/resources/views/employers/add_vacancy.blade.php index ea96ce4..b9f2e44 100644 --- a/resources/views/employers/add_vacancy.blade.php +++ b/resources/views/employers/add_vacancy.blade.php @@ -99,10 +99,10 @@ -