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') +
+
+ + + + + + + + + + + + + @foreach($roles as $role) + + + + + + + + + + @endforeach + +
РазделURL-страницыАдминМенеджерДата регист.
+ {{$role->id}} + + {{$role->name}} + + {{ $role->url_page }} + + {{ $role->is_admin }} + + {{ $role->is_manager }} + + {{ date('d.m.Y', strtotime($role->created_at)) }} +
+
+ +
+ appends($_GET)->links('admin.pagginate'); ?> + {{$roles->links('admin.pagginate') }} +
+
+ +@endsection diff --git a/resources/views/admin/content/roles_index_ajax.blade.php b/resources/views/admin/content/roles_index_ajax.blade.php new file mode 100644 index 0000000..e69de29 diff --git a/resources/views/admin/employer/index.blade.php b/resources/views/admin/employer/index.blade.php index 38c9bbf..99b9715 100644 --- a/resources/views/admin/employer/index.blade.php +++ b/resources/views/admin/employer/index.blade.php @@ -116,6 +116,10 @@ +
+

Количество: {{ $all_current }}

+
+
diff --git a/resources/views/admin/users/index.blade.php b/resources/views/admin/users/index.blade.php index 0425b47..8ebf994 100644 --- a/resources/views/admin/users/index.blade.php +++ b/resources/views/admin/users/index.blade.php @@ -54,43 +54,26 @@ - - - - - - + + + + @if ($id_admin == 1) - + @endif - + @foreach($users as $user) - - - - - - @if ($id_admin == 1) - @endif - diff --git a/resources/views/admin/users/index_ajax.blade.php b/resources/views/admin/users/index_ajax.blade.php index 966518b..9ae32df 100644 --- a/resources/views/admin/users/index_ajax.blade.php +++ b/resources/views/admin/users/index_ajax.blade.php @@ -4,65 +4,60 @@ - - - - - - + + + + @if ($id_admin == 1) - + @endif - + @foreach($users as $user) - - - - - + + + + - - - - @if ($id_admin == 1) - - @endif - - + @if ($id_admin == 1) + + @endif + + + @endforeach
ИмяEmail/логинРаботодатель/работник/администраторБанНовыйИмяEmail/логинРаботодатель/работник/администраторАдминАдминДата регист.Дата регист.
+ {{$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 ($user->id > 1) admin) ? "checked" : "" }}/> @endif + {{ date('d.m.Y', strtotime($user->created_at)) }}
ИмяEmail/логинРаботодатель/работник/администраторБанНовыйИмяEmail/логинРаботодатель/работник/администраторАдминАдминДата регистрацииДата регист.
- {{$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 ($user->id > 1) - admin) ? "checked" : "" }}/> + @endif + @if ($user->is_bd) + + База данных + @endif - {{ date('d.m.Y', strtotime($user->created_at)) }} -
+ @if ($user->id > 1) + admin) ? "checked" : "" }}/> + @endif + + {{ date('d.m.Y', strtotime($user->created_at)) }} +
diff --git a/resources/views/layout/admin.blade.php b/resources/views/layout/admin.blade.php index abb46f2..f24e8c0 100644 --- a/resources/views/layout/admin.blade.php +++ b/resources/views/layout/admin.blade.php @@ -32,14 +32,14 @@ href="{{ route('admin.index') }}"> Админка +