diff --git a/app/Http/Controllers/Admin/EmployersController.php b/app/Http/Controllers/Admin/EmployersController.php index fddae54..2c8d2af 100644 --- a/app/Http/Controllers/Admin/EmployersController.php +++ b/app/Http/Controllers/Admin/EmployersController.php @@ -59,6 +59,7 @@ class EmployersController extends Controller } //DB::enableQueryLog(); + $all_current = $users->count(); $users = $users->paginate(15); //dd(DB::getQueryLog()); @@ -73,6 +74,7 @@ class EmployersController extends Controller 'all_employer', 'all_public', 'all_status', + 'all_current', 'select_category')); } } diff --git a/app/Http/Controllers/Admin/UsersController.php b/app/Http/Controllers/Admin/UsersController.php index 2ba22d8..4f2a512 100644 --- a/app/Http/Controllers/Admin/UsersController.php +++ b/app/Http/Controllers/Admin/UsersController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; use App\Http\Requests\BaseUserRequest; +use App\Models\ContentRoles; use App\Models\Job_title; use App\Models\User; use App\Models\Worker; @@ -146,6 +147,23 @@ class UsersController extends Controller } } + public function admin_roles(Request $request) { + + if ($request->ajax()) { + $content_roles = ContentRoles::find($request->id); + $request->offsetUnset($request->id); + $content_roles->update($request->all()); + } + $roles = ContentRoles::query()->OrderBy('name')->paginate(25); + + + if ($request->ajax()) { + return view('admin.content.roles_index_ajax', compact('roles')); + } else { + return view('admin.content.roles_index', compact('roles')); + } + } + public function doc_bd(User $user) { $id = $user->id; $spreadsheet = new Spreadsheet(); diff --git a/app/Models/ContentRoles.php b/app/Models/ContentRoles.php new file mode 100644 index 0000000..830a5cc --- /dev/null +++ b/app/Models/ContentRoles.php @@ -0,0 +1,11 @@ +id; + $is_manager = Auth::user()->is_manager; + $admin = Auth::user()->admin; + + $contents = ContentRoles::query()->get(); + $query = DB::select(DB::raw('SELECT count(*) as MsgCount FROM messages m1 Where ((m1.flag_new = 1) and (m1.to_user_id = :uid)) '), ['uid' => $id] ); - $view->with(['MsgCount' => $query[0]->MsgCount, 'UserId' => $id]); + $view->with(['MsgCount' => $query[0]->MsgCount, + 'UserId' => $id, + 'is_manager' => $is_manager, + 'admin' => $admin, + 'contents' => $contents]); } ); } diff --git a/database/migrations/2023_11_20_062736_alter_users_table.php b/database/migrations/2023_11_20_062736_alter_users_table.php new file mode 100644 index 0000000..7230b59 --- /dev/null +++ b/database/migrations/2023_11_20_062736_alter_users_table.php @@ -0,0 +1,32 @@ +boolean('is_manager')->default(1); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn('is_manager'); + }); + } +}; diff --git a/database/migrations/2023_11_20_064430_create_content_roles_table.php b/database/migrations/2023_11_20_064430_create_content_roles_table.php new file mode 100644 index 0000000..399db15 --- /dev/null +++ b/database/migrations/2023_11_20_064430_create_content_roles_table.php @@ -0,0 +1,34 @@ +id(); + $table->string('url_page', 255); + $table->boolean('is_admin')->default(1); + $table->boolean('is_manager')->default(0); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('content_roles'); + } +}; diff --git a/database/migrations/2023_11_20_070121_alter_content_roles_table.php b/database/migrations/2023_11_20_070121_alter_content_roles_table.php new file mode 100644 index 0000000..b53331f --- /dev/null +++ b/database/migrations/2023_11_20_070121_alter_content_roles_table.php @@ -0,0 +1,32 @@ +string('name', 255)->nullable(false); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('content_roles', function (Blueprint $table) { + $table->dropColumn('name'); + }); + } +}; diff --git a/resources/views/admin/content/roles_index.blade.php b/resources/views/admin/content/roles_index.blade.php new file mode 100644 index 0000000..63ef07f --- /dev/null +++ b/resources/views/admin/content/roles_index.blade.php @@ -0,0 +1,95 @@ +@extends('layout.admin', ['title' => 'Роли администраторов и менеджеров для каждой страницы']) + +@section('script') + +@endsection + +@section('content') +
№ | +Раздел | +URL-страницы | +Админ | +Менеджер | +Дата регист. | +
---|---|---|---|---|---|
+ {{$role->id}} + | ++ {{$role->name}} + | ++ {{ $role->url_page }} + | ++ {{ $role->is_admin }} + | ++ {{ $role->is_manager }} + | + ++ {{ date('d.m.Y', strtotime($role->created_at)) }} + | +
Количество: {{ $all_current }}
+№ | -Имя | -Email/логин | -Работодатель/работник/администратор | -Бан | -Новый | +№ | +Имя | +Email/логин | +Работодатель/работник/администратор | @if ($id_admin == 1) -Админ | +Админ | @endif -Дата регист. | +Дата регист. |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+ | {{$user->id}} | -- - {{ $user->name }} + | + {{ $user->name }} | -+ | {{ $user->email }} | @@ -112,25 +95,16 @@ @endif | -- @if ($user->id > 1) - is_ban) ? "checked" : "" }}/> - @endif - | - -- is_new) ? "checked" : "" }}/> - | @if ($id_admin == 1) -+ | @if ($user->id > 1) admin) ? "checked" : "" }}/> @endif | @endif -+ | {{ date('d.m.Y', strtotime($user->created_at)) }} | |
№ | -Имя | -Email/логин | -Работодатель/работник/администратор | -Бан | -Новый | +№ | +Имя | +Email/логин | +Работодатель/работник/администратор | @if ($id_admin == 1) -Админ | +Админ | @endif -Дата регистрации | +Дата регист. |
- {{$user->id}} - | -- {{ $user->name }} - | -- {{ $user->email }} - | -+ | ||||||||||
+ {{$user->id}} + | ++ {{ $user->name }} + | ++ {{ $user->email }} + | +@if ($user->is_worker) - Работник - @else - Работодатель - @endif + Работник + @else + Работодатель + @endif - @if ($user->admin) - + @if ($user->admin) + Администратор - @endif - | -- @if ($user->id > 1) - is_ban) ? "checked" : "" }}/> - @endif - | -- is_new) ? "checked" : "" }}/> - | - - @if ($id_admin == 1) -- @if ($user->id > 1) - admin) ? "checked" : "" }}/> + @endif + @if ($user->is_bd) + + База данных + @endif | - @endif -- {{ date('d.m.Y', strtotime($user->created_at)) }} - | -+ @if ($user->id > 1) + admin) ? "checked" : "" }}/> + @endif + | + @endif + ++ {{ date('d.m.Y', strtotime($user->created_at)) }} + | + @endforeach