From 36b239fd916a9c8b7e77c2239112ad506c7fee52 Mon Sep 17 00:00:00 2001 From: anazaryan Date: Thu, 28 Nov 2024 18:28:05 +0400 Subject: [PATCH] user role fixes --- app/Http/Controllers/Admin/EmployersController.php | 9 +++ app/Http/Controllers/EmployerController.php | 10 +++- app/Models/User.php | 2 + ...024_11_28_110548_add_columns_in_users_table.php | 33 +++++++++++ .../views/admin/content/roles_index.blade.php | 1 - resources/views/admin/employer/edit.blade.php | 58 ++++++++++++++----- resources/views/admin/users/roles/index.blade.php | 13 +++-- .../views/admin/users/roles/index_ajax.blade.php | 8 +++ resources/views/employers/menu.blade.php | 60 ++++++++++++-------- 9 files changed, 150 insertions(+), 44 deletions(-) create mode 100644 database/migrations/2024_11_28_110548_add_columns_in_users_table.php diff --git a/app/Http/Controllers/Admin/EmployersController.php b/app/Http/Controllers/Admin/EmployersController.php index 7e1602c..3cbfadf 100644 --- a/app/Http/Controllers/Admin/EmployersController.php +++ b/app/Http/Controllers/Admin/EmployersController.php @@ -139,6 +139,9 @@ class EmployersController extends Controller unset($params['email']); unset($params['address']); unset($params['site']); + unset($params['is_lookin']); + unset($params['show_database']); + unset($params['can_autolift']); unset($params['status_hidden']); unset($params['oficial_status']); unset($params['social_is']); @@ -196,6 +199,12 @@ class EmployersController extends Controller } $employer->save(); + $employer->users()->update([ + 'is_lookin' => $request->is_lookin, + 'show_database' => $request->show_database, + 'can_autolift' => $request->can_autolift, + ]); + return redirect()->route('admin.employer-profile', ['employer' => $employer->id]) ->with('success', 'Данные были успешно сохранены'); } diff --git a/app/Http/Controllers/EmployerController.php b/app/Http/Controllers/EmployerController.php index 094bd94..9e45798 100644 --- a/app/Http/Controllers/EmployerController.php +++ b/app/Http/Controllers/EmployerController.php @@ -566,6 +566,10 @@ class EmployerController extends Controller // База данных public function bd(Request $request) { + if (!Auth::user()->show_database) { + return redirect()->route('employer.employer_info'); + } + $users = User_Model::query()->with('workers')->with('jobtitles'); if ($request->has('search')) { @@ -793,8 +797,12 @@ class EmployerController extends Controller /** * @throws JsonException */ - public function vacancyAutoLiftForm(): View + public function vacancyAutoLiftForm(): View|RedirectResponse { + if (!Auth::user()->can_autolift) { + return redirect()->route('employer.employer_info'); + } + $employer = Auth::user()->employers[0]; $vacancies = $employer ->ads() diff --git a/app/Models/User.php b/app/Models/User.php index a03b46d..3fcab18 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -32,6 +32,8 @@ class User extends Authenticatable implements MustVerifyEmail 'surname2', 'is_worker', 'is_lookin', + 'show_database', + 'can_autolift', 'is_message', 'is_public', 'is_worker', diff --git a/database/migrations/2024_11_28_110548_add_columns_in_users_table.php b/database/migrations/2024_11_28_110548_add_columns_in_users_table.php new file mode 100644 index 0000000..4455ee3 --- /dev/null +++ b/database/migrations/2024_11_28_110548_add_columns_in_users_table.php @@ -0,0 +1,33 @@ +boolean('show_database')->default(false)->after('is_lookin'); + $table->boolean('can_autolift')->default(false)->after('show_database'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn(['show_database', 'can_autolift']); + }); + } +}; diff --git a/resources/views/admin/content/roles_index.blade.php b/resources/views/admin/content/roles_index.blade.php index 52ddf74..b0bce51 100644 --- a/resources/views/admin/content/roles_index.blade.php +++ b/resources/views/admin/content/roles_index.blade.php @@ -90,7 +90,6 @@
- appends($_GET)->links('admin.pagginate'); ?> {{$roles->links('admin.pagginate') }}
diff --git a/resources/views/admin/employer/edit.blade.php b/resources/views/admin/employer/edit.blade.php index fb5910e..f643346 100644 --- a/resources/views/admin/employer/edit.blade.php +++ b/resources/views/admin/employer/edit.blade.php @@ -172,34 +172,66 @@
- +
- appends($_GET)->links('admin.pagginate'); ?> links('admin.pagginate'); ?>
@@ -232,7 +240,4 @@ --> - appends($_GET)->links('catalogs.paginate'); ?> - - @endsection diff --git a/resources/views/admin/users/roles/index_ajax.blade.php b/resources/views/admin/users/roles/index_ajax.blade.php index 3f682f8..8c99d9c 100644 --- a/resources/views/admin/users/roles/index_ajax.blade.php +++ b/resources/views/admin/users/roles/index_ajax.blade.php @@ -8,6 +8,8 @@ Имя Email/логин Просмотр резюме + Просмотр базы данных + Автоподнятие вакансий Отправка сообщений Публикация вакансий Админ @@ -29,8 +31,14 @@ is_lookin) ? "checked" : "" }}/> + + show_database) ? "checked" : "" }}/> + + can_autolift) ? "checked" : "" }}/> + + is_message) ? "checked" : "" }}/> diff --git a/resources/views/employers/menu.blade.php b/resources/views/employers/menu.blade.php index 43ea28e..ad69e3c 100644 --- a/resources/views/employers/menu.blade.php +++ b/resources/views/employers/menu.blade.php @@ -69,32 +69,42 @@ Избранные кандидаты - - - - - - - Автоподнятие вакансий - - @if ((!Auth()->user()->is_worker) && (Auth()->user()->is_lookin)) - - - - - - - База данных - - - - - - - - База резюме - + @if ((!Auth()->user()->is_worker)) + @if(Auth()->user()->can_autolift) + + + + + + + Автоподнятие вакансий + + @endif + + @if(Auth()->user()->show_database) + + + + + + + База данных + + @endif + + @if(Auth()->user()->is_lookin) + + + + + + + База резюме + + @endif @endif + + -- 1.7.10.4