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
+
+
+
+