From 32cbe773645d2eaf6bd951306ea05fbe51e3c539 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: Fri, 22 Sep 2023 14:35:15 +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=B1=D0=BB=D0=B5=D0=B9=D0=B4=D0=BE=D0=B2,=20=D1=80=D0?= =?UTF-8?q?=B0=D1=81=D1=88=D0=B8=D1=80=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BC=D0=BE?= =?UTF-8?q?=D0=B4=D0=B5=D0=BB=D0=B5=D0=B9=20=D0=BA=D0=BE=D0=BC=D0=BF=D0=B0=D0?= =?UTF-8?q?=BD=D0=B8=D1=8F=20=D0=B8=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BD=D0?= =?UTF-8?q?=B8=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Admin/AdminController.php | 6 +- app/Http/Controllers/Admin/WorkersController.php | 57 ++++- app/Http/Requests/CompanyRequest.php | 9 +- app/Models/Company.php | 2 + app/Models/Worker.php | 2 + .../2023_09_21_112115_alter_workers_table.php | 35 +++ resources/views/admin/category/form.blade.php | 4 + resources/views/admin/config.blade.php | 26 +++ resources/views/admin/editbloks/form.blade.php | 4 + resources/views/admin/employer/edit.blade.php | 5 + resources/views/admin/infobloks/form.blade.php | 4 + resources/views/admin/job_titles/form.blade.php | 5 + resources/views/admin/pages/form.blade.php | 4 + resources/views/admin/profile.blade.php | 5 +- resources/views/admin/reclames/add.blade.php | 1 + resources/views/admin/reclames/edit.blade.php | 4 + resources/views/admin/reclames/form.blade.php | 14 +- resources/views/admin/seo/form.blade.php | 4 + resources/views/admin/users/index.blade.php | 2 +- resources/views/admin/users/profile.blade.php | 14 +- resources/views/admin/worker/edit.blade.php | 236 ++++++++++++-------- resources/views/admin/worker/index.blade.php | 2 +- resources/views/admin/worker/index_ajax.blade.php | 2 +- resources/views/layout/admin.blade.php | 2 +- routes/web.php | 5 +- 25 files changed, 331 insertions(+), 123 deletions(-) create mode 100644 database/migrations/2023_09_21_112115_alter_workers_table.php diff --git a/app/Http/Controllers/Admin/AdminController.php b/app/Http/Controllers/Admin/AdminController.php index 29868cc..a6691dc 100644 --- a/app/Http/Controllers/Admin/AdminController.php +++ b/app/Http/Controllers/Admin/AdminController.php @@ -179,8 +179,8 @@ class AdminController extends Controller if($user->is_worker) { $caption = "Карточка работника"; if (isset($user->workers[0]->id)) { - $link = route('admin.worker-profile', ['worker' => $user->workers[0]->id]); - //$visible = true; + $link = route('admin.worker-profile-edit', ['worker' => $user->workers[0]->id]); + $visible = true; } else { $link = ""; } @@ -190,7 +190,7 @@ class AdminController extends Controller if (isset($user->employers[0]->id)) { $link = route('admin.employer-profile', ['employer' => $user->employers[0]->id]); - //$visible = true; + $visible = true; } else { $link = ""; } diff --git a/app/Http/Controllers/Admin/WorkersController.php b/app/Http/Controllers/Admin/WorkersController.php index bcca5ca..f17e2e4 100644 --- a/app/Http/Controllers/Admin/WorkersController.php +++ b/app/Http/Controllers/Admin/WorkersController.php @@ -3,10 +3,14 @@ namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; +use App\Models\Company; +use App\Models\Job_title; use App\Models\Static_worker; use App\Models\User; use App\Models\Worker; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Storage; +use Illuminate\Support\Facades\Validator; class WorkersController extends Controller { @@ -37,8 +41,57 @@ class WorkersController extends Controller } } - public function form_update_worker(Worker $worker) { - return view('admin.worker.edit'); + public function form_edit_worker(Worker $worker) { + $job_titles = Job_title::query()->active()->orderBy('name')->get(); + + $time_end_anketa = 'Бессрочно'; + if (!empty($worker->updated_at)) { + $long_days = Company::find(1)->time_resume; + $time_end_anketa = date("d.m.Y H:i:s", strtotime($worker->updated_at . "+$long_days days")); + } + return view('admin.worker.edit', compact('worker', 'job_titles', 'time_end_anketa')); + } + + public function form_update_worker(Request $request, Worker $worker) + { + $params = $request->all(); + + $rules = [ + 'email' => 'email|string|max:255', + //'photo' => 'mimes:jpeg,jpg,png|max:15000', + ]; + + $messages = [ + 'required' => 'Укажите обязательное поле «:attribute»', + 'confirmed' => 'Пароли не совпадают', + 'email' => 'Введите корректный email', + 'min' => [ + 'string' => 'Поле «:attribute» должно быть не меньше :min символов', + 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' + ], + 'max' => [ + 'string' => 'Поле «:attribute» должно быть не больше :max символов', + 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' + ], + ]; + + $validator = Validator::make($params, $rules, $messages); + + if ($validator->fails()) { + return back()->withErrors($validator)->withInput(); + } else { + $user_id = $worker->user_id; + if ($request->has('photo')) { + if (!empty($worker->photo)) { + Storage::delete($worker->photo); + } + if (!empty($request->photo)) + $params['photo'] = $request->file('photo')->store("workers/$user_id", 'public'); + } + $worker->update($params); + + return redirect()->route('admin.workers'); + } } // кабинет - статистика работников diff --git a/app/Http/Requests/CompanyRequest.php b/app/Http/Requests/CompanyRequest.php index de8954b..3c5d834 100644 --- a/app/Http/Requests/CompanyRequest.php +++ b/app/Http/Requests/CompanyRequest.php @@ -34,19 +34,24 @@ class CompanyRequest extends FormRequest 'mimes:jpeg,jpg,png', 'max:10000' ], + 'time_mess' => 'required|numeric|min:0|max:365', + 'time_resume' => 'required|numeric|min:0|max:365', ]; } public function messages() { return [ 'required' => 'Поле :attribute обязательно для ввода', + 'numeric' => 'Поле :attribute должно быть целым числом', 'min' => [ 'string' => 'Поле «:attribute» должно быть не меньше :min символов', - 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' + 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт', + 'numeric' => 'Поле «:attribute» должно быть не меньше :min', ], 'max' => [ 'string' => 'Поле «:attribute» должно быть не больше :max символов', - 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' + 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт', + 'numeric' => 'Поле «:attribute» должно быть не больше :max', ], 'email' => 'Это поле должно быть формата email', ]; diff --git a/app/Models/Company.php b/app/Models/Company.php index 4f829d7..3b9fee1 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -22,5 +22,7 @@ class Company extends Model 'image', 'map', 'text', + 'time_mess', + 'time_resume' ]; } diff --git a/app/Models/Worker.php b/app/Models/Worker.php index d5ab505..cac064b 100644 --- a/app/Models/Worker.php +++ b/app/Models/Worker.php @@ -42,6 +42,8 @@ class Worker extends Model 'coord', 'file', 'is_remove', + 'favorite_user', + 'sroch_user' ]; /* diff --git a/database/migrations/2023_09_21_112115_alter_workers_table.php b/database/migrations/2023_09_21_112115_alter_workers_table.php new file mode 100644 index 0000000..7e2909e --- /dev/null +++ b/database/migrations/2023_09_21_112115_alter_workers_table.php @@ -0,0 +1,35 @@ +boolean('favorite_user')->default(false); + $table->boolean('sroch_user')->default(false); + + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('workers', function (Blueprint $table) { + $table->dropColumn('favorite_user'); + $table->dropColumn('sroch_user'); + }); + } +}; diff --git a/resources/views/admin/category/form.blade.php b/resources/views/admin/category/form.blade.php index ebd0eef..c4f57a0 100644 --- a/resources/views/admin/category/form.blade.php +++ b/resources/views/admin/category/form.blade.php @@ -23,6 +23,10 @@ + Назад diff --git a/resources/views/admin/config.blade.php b/resources/views/admin/config.blade.php index b3b25de..5a01be3 100644 --- a/resources/views/admin/config.blade.php +++ b/resources/views/admin/config.blade.php @@ -177,6 +177,32 @@ @enderror
+
+ +
+
+ Назад
diff --git a/resources/views/admin/employer/edit.blade.php b/resources/views/admin/employer/edit.blade.php index d3c7eaf..c512bd0 100644 --- a/resources/views/admin/employer/edit.blade.php +++ b/resources/views/admin/employer/edit.blade.php @@ -183,6 +183,11 @@ + Назад + - {{ $user->name }} + {{ $user->name }} {{ $user->email }} diff --git a/resources/views/admin/users/profile.blade.php b/resources/views/admin/users/profile.blade.php index 20c35de..5e975c9 100644 --- a/resources/views/admin/users/profile.blade.php +++ b/resources/views/admin/users/profile.blade.php @@ -92,12 +92,16 @@ - -
+ Назад @if ($visible==true) - - {{ $caption }} - + + {{ $caption }} + @endif
diff --git a/resources/views/admin/worker/edit.blade.php b/resources/views/admin/worker/edit.blade.php index 1c7e461..6530a6a 100644 --- a/resources/views/admin/worker/edit.blade.php +++ b/resources/views/admin/worker/edit.blade.php @@ -1,122 +1,166 @@ + @extends('layout.admin', ['title' => 'Админка - Редактирование соискателя']) @section('content')

- Соискатель-пользователь: "{{$worker->users->name_man}} ({{$worker->user_id}})" + Соискатель-пользователь: "{{$worker->users->surname}} {{$worker->users->name_man}} {{$worker->users->surname2}} ({{$worker->user_id}})"

@csrf
-
+
+ + + + + +
+
-
+ -
+
+
+
- - @isset('photo') - - @endisset - @error('logo') - - {{ $message }} - - @enderror -
+
-
+
+ +
- +
+ + + + +
+
+ +
+

+ Назад
diff --git a/resources/views/admin/worker/index.blade.php b/resources/views/admin/worker/index.blade.php index 12c50a9..2c876b0 100644 --- a/resources/views/admin/worker/index.blade.php +++ b/resources/views/admin/worker/index.blade.php @@ -100,7 +100,7 @@ @if ($user->id > 1) - Изменить + Изменить @endif diff --git a/resources/views/admin/worker/index_ajax.blade.php b/resources/views/admin/worker/index_ajax.blade.php index de4bab4..0e5e9a7 100644 --- a/resources/views/admin/worker/index_ajax.blade.php +++ b/resources/views/admin/worker/index_ajax.blade.php @@ -54,7 +54,7 @@ @if ($user->id > 1) - Изменить + Изменить @endif diff --git a/resources/views/layout/admin.blade.php b/resources/views/layout/admin.blade.php index 852c59c..2c795cf 100644 --- a/resources/views/layout/admin.blade.php +++ b/resources/views/layout/admin.blade.php @@ -1043,7 +1043,7 @@ d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z" > - Вход в админку только для пользователей-админов + Контент для админов Список админов → diff --git a/routes/web.php b/routes/web.php index cdab12e..ea807db 100644 --- a/routes/web.php +++ b/routes/web.php @@ -112,7 +112,10 @@ Route::group([ Route::post('employer-profile/{employer}', [EmployersController::class, 'update_employer'])->name('update-employer-profile'); // кабинет профиль работник - форма - Route::post('worker-profile/{worker}', [WorkersController::class, 'form_update_worker'])->name('worker-profile'); + Route::get('worker-profile/{worker}', [WorkersController::class, 'form_edit_worker'])->name('worker-profile-edit'); + // кабинет профиль работник - сохранение формы + Route::post('worker-profile/{worker}', [WorkersController::class, 'form_update_worker'])->name('worker-profile-update'); + // кабинет настройки сайта - форма Route::get('config', [AdminController::class, 'config_form'])->name('config'); -- 1.7.10.4