Commit 29350503f1ddb5f83f6fbcb1e3fdc8cd8dcb45b5
1 parent
82a9544dc9
Exists in
master
and in
1 other branch
Расширение полей моделей, группы и категории справочники
Showing 23 changed files with 812 additions and 19 deletions Side-by-side Diff
- app/Http/Controllers/Admin/CategoryController.php
- app/Http/Controllers/Admin/EmployersController.php
- app/Http/Controllers/Admin/GroupsController.php
- app/Http/Controllers/Admin/UsersController.php
- app/Models/Ad_employer.php
- app/Models/Answer.php
- app/Models/Category.php
- app/Models/Employer.php
- app/Models/Group_user.php
- app/Models/Group_works.php
- app/Models/Job_title.php
- app/Models/User.php
- app/Models/Worker.php
- database/migrations/2023_09_07_134401_alter_group_users_table.php
- resources/views/admin/answers/index.blade.php
- resources/views/admin/answers/index_ajax.blade.php
- resources/views/admin/category/index.blade.php
- resources/views/admin/groups/form.blade.php
- resources/views/admin/groups/index.blade.php
- resources/views/admin/static/index.blade.php
- resources/views/admin/users/roles/index.blade.php
- resources/views/admin/users/roles/index_ajax.blade.php
- routes/web.php
app/Http/Controllers/Admin/CategoryController.php
... | ... | @@ -18,7 +18,7 @@ class CategoryController extends Controller |
18 | 18 | */ |
19 | 19 | public function index() |
20 | 20 | { |
21 | - $category = Category::query()->paginate(15); | |
21 | + $category = Category::query()->active()->paginate(15); | |
22 | 22 | return view('admin.category.index', compact('category')); |
23 | 23 | } |
24 | 24 | |
... | ... | @@ -87,9 +87,11 @@ class CategoryController extends Controller |
87 | 87 | */ |
88 | 88 | public function destroy(Category $category) |
89 | 89 | { |
90 | - if (Auth::user()->id == 1) { | |
90 | + /*if (Auth::user()->id == 1) { | |
91 | 91 | $category->delete(); |
92 | - } | |
92 | + } else {*/ | |
93 | + $category->update(['is_remove' => 1]); | |
94 | + //} | |
93 | 95 | return redirect()->route('admin.categories.index'); |
94 | 96 | } |
95 | 97 | } |
app/Http/Controllers/Admin/EmployersController.php
... | ... | @@ -3,6 +3,7 @@ |
3 | 3 | namespace App\Http\Controllers\Admin; |
4 | 4 | |
5 | 5 | use App\Http\Controllers\Controller; |
6 | +use App\Models\Answer; | |
6 | 7 | use App\Models\Employer; |
7 | 8 | use App\Models\User; |
8 | 9 | use Illuminate\Http\Request; |
... | ... | @@ -89,8 +90,20 @@ class EmployersController extends Controller |
89 | 90 | } |
90 | 91 | |
91 | 92 | // кабинет - отзывы о работодателе для модерации |
92 | - public function answers() { | |
93 | - return; | |
93 | + public function answers(Request $request) { | |
94 | + if ($request->ajax()) { | |
95 | + $user = Answer::find($request->id); | |
96 | + $request->offsetUnset('id'); | |
97 | + $user->update($request->all()); | |
98 | + } | |
99 | + | |
100 | + $answers = Answer::query()->orderByDesc('id')->paginate(15); | |
101 | + | |
102 | + if ($request->ajax()) { | |
103 | + return view('admin.answers.index_ajax', compact('answers')); | |
104 | + } else { | |
105 | + return view('admin.answers.index', compact('answers')); | |
106 | + } | |
94 | 107 | } |
95 | 108 | |
96 | 109 | // кабинет - статистика вакансий работодателя |
app/Http/Controllers/Admin/GroupsController.php
... | ... | @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Admin; |
4 | 4 | |
5 | 5 | use App\Http\Controllers\Controller; |
6 | 6 | use App\Models\Group_user; |
7 | +use App\Models\User; | |
7 | 8 | use Illuminate\Http\Request; |
8 | 9 | use Illuminate\Support\Facades\Auth; |
9 | 10 | use Illuminate\Support\Facades\Validator; |
... | ... | @@ -12,14 +13,15 @@ class GroupsController extends Controller |
12 | 13 | { |
13 | 14 | // индексная страница |
14 | 15 | public function index() { |
15 | - $groups = Group_user::query()->paginate(15); | |
16 | + $groups = Group_user::query()->active()->paginate(15); | |
16 | 17 | return view('admin.groups.index', compact('groups')); |
17 | 18 | } |
18 | 19 | |
19 | 20 | // форма добавления группы |
20 | 21 | public function add() { |
21 | 22 | $editor = Auth::user()->id; |
22 | - return view('admin.groups.add', compact('editor')); | |
23 | + $users = User::query()->get(); | |
24 | + return view('admin.groups.add', compact('editor', 'users')); | |
23 | 25 | } |
24 | 26 | |
25 | 27 | // форма сохранения добавленной группы |
... | ... | @@ -46,11 +48,15 @@ class GroupsController extends Controller |
46 | 48 | // форма редактирования группы |
47 | 49 | public function edit(Group_user $group, Request $request) { |
48 | 50 | $editor = Auth::user()->id; |
49 | - return view('admin.groups.edit', compact('editor', 'group')); | |
51 | + $users = User::query()->get(); | |
52 | + return view('admin.groups.edit', compact('editor', 'group', 'users')); | |
50 | 53 | } |
51 | 54 | |
52 | 55 | // форма сохранения редактированной группы |
53 | 56 | public function update(Group_user $group, Request $request) { |
57 | + | |
58 | + $params = $request->all(); | |
59 | + unset($params['usergroup']); | |
54 | 60 | $rules = [ |
55 | 61 | 'name_group' => 'required|min:3', |
56 | 62 | ]; |
... | ... | @@ -64,9 +70,22 @@ class GroupsController extends Controller |
64 | 70 | ->withErrors($validator); |
65 | 71 | } else { |
66 | 72 | $group->update($request->all()); |
73 | + $group->ingroup()->sync($request->usergroup); | |
74 | + /*if ($request->usergroup->count()) { | |
75 | + foreach ($request->usergroup as $us) { | |
76 | + Group_works | |
77 | + } | |
78 | + }*/ | |
79 | + | |
67 | 80 | return redirect()->route('admin.groups') |
68 | 81 | ->with('success', 'Данные были успешно сохранены'); |
69 | 82 | } |
70 | 83 | return redirect()->route('admin.groups'); |
71 | 84 | } |
85 | + | |
86 | + public function destroy(Group_user $group) { | |
87 | + $group->update(['is_remove' => 1]); | |
88 | + | |
89 | + return redirect()->route('admin.groups'); | |
90 | + } | |
72 | 91 | } |
app/Http/Controllers/Admin/UsersController.php
... | ... | @@ -27,7 +27,19 @@ class UsersController extends Controller |
27 | 27 | } |
28 | 28 | } |
29 | 29 | |
30 | - public function roles() { | |
31 | - return; | |
30 | + public function roles(Request $request) { | |
31 | + if ($request->ajax()) { | |
32 | + $user = User::find($request->id); | |
33 | + $request->offsetUnset('id'); | |
34 | + $user->update($request->all()); | |
35 | + } | |
36 | + | |
37 | + $users = User::query()->paginate(15); | |
38 | + | |
39 | + if ($request->ajax()) { | |
40 | + return view('admin.users.roles.index_ajax', compact('users')); | |
41 | + } else { | |
42 | + return view('admin.users.roles.index', compact('users')); | |
43 | + } | |
32 | 44 | } |
33 | 45 | } |
app/Models/Ad_employer.php
... | ... | @@ -9,6 +9,19 @@ class Ad_employer extends Model |
9 | 9 | { |
10 | 10 | use HasFactory; |
11 | 11 | |
12 | + protected $fillable = [ | |
13 | + 'name', | |
14 | + 'telephone', | |
15 | + 'email', | |
16 | + 'salary', | |
17 | + 'category_id', | |
18 | + 'text', | |
19 | + 'employer_id', | |
20 | + 'city', | |
21 | + 'sort', | |
22 | + 'is_remove', | |
23 | + 'active_is', | |
24 | + ]; | |
12 | 25 | /* |
13 | 26 | * Связь таблицы employers с таблицей ad_employers |
14 | 27 | многие-к-одному |
... | ... | @@ -32,4 +45,8 @@ class Ad_employer extends Model |
32 | 45 | public function response() { |
33 | 46 | return $this->hasMany(ad_response::class); |
34 | 47 | } |
48 | + | |
49 | + public function scopeActive($query) { | |
50 | + return $query->where('is_remove', '=', '0'); | |
51 | + } | |
35 | 52 | } |
app/Models/Answer.php
... | ... | @@ -8,4 +8,32 @@ use Illuminate\Database\Eloquent\Model; |
8 | 8 | class Answer extends Model |
9 | 9 | { |
10 | 10 | use HasFactory; |
11 | + | |
12 | + protected $fillable = [ | |
13 | + 'employer_id', | |
14 | + 'user_id', | |
15 | + 'plus', | |
16 | + 'minus', | |
17 | + 'rate', | |
18 | + 'title', | |
19 | + 'text', | |
20 | + 'is_moderate', | |
21 | + ]; | |
22 | + | |
23 | + /* | |
24 | + * Связь таблицы employers с таблицей answers | |
25 | + многие-к-одному | |
26 | + */ | |
27 | + public function employer() { | |
28 | + return $this->belongsTo(Employer::class, 'employer_id'); | |
29 | + } | |
30 | + | |
31 | + /* | |
32 | + * Связь таблицы users с таблицей answers | |
33 | + многие-к-одному | |
34 | + */ | |
35 | + public function user() { | |
36 | + return $this->belongsTo(User::class, 'user_id'); | |
37 | + } | |
38 | + | |
11 | 39 | } |
app/Models/Category.php
app/Models/Employer.php
... | ... | @@ -21,6 +21,12 @@ class Employer extends Model |
21 | 21 | 'address', |
22 | 22 | 'map', |
23 | 23 | 'site', |
24 | + 'coord', | |
25 | + 'plus', | |
26 | + 'is_remove', | |
27 | + 'oficial_status', | |
28 | + 'social_is', | |
29 | + 'sending_is', | |
24 | 30 | ]; |
25 | 31 | |
26 | 32 | /* |
... | ... | @@ -37,5 +43,8 @@ class Employer extends Model |
37 | 43 | return $this->hasMany(Ad_employer::class); |
38 | 44 | } |
39 | 45 | |
46 | + public function scopeActive($query) { | |
47 | + return $query->where('is_remove', '=', '0'); | |
48 | + } | |
40 | 49 | |
41 | 50 | } |
app/Models/Group_user.php
... | ... | @@ -12,6 +12,7 @@ class Group_user extends Model |
12 | 12 | protected $fillable = [ |
13 | 13 | 'name_group', |
14 | 14 | 'user_id', |
15 | + 'is_remove', | |
15 | 16 | ]; |
16 | 17 | |
17 | 18 | /* |
... | ... | @@ -30,4 +31,16 @@ class Group_user extends Model |
30 | 31 | return $this->belongsToMany(User::class, 'group_works'); |
31 | 32 | } |
32 | 33 | |
34 | + /* | |
35 | + * Связь модели Группы (Group_users) с моделью Группы пользователей (Group_works) | |
36 | + один-ко-многим | |
37 | + */ | |
38 | + public function peoples() { | |
39 | + return $this->hasMany(Group_works::class); | |
40 | + } | |
41 | + | |
42 | + public function scopeActive($query) { | |
43 | + return $query->where('is_remove', '=', '0'); | |
44 | + } | |
45 | + | |
33 | 46 | } |
app/Models/Group_works.php
... | ... | @@ -0,0 +1,35 @@ |
1 | +<?php | |
2 | + | |
3 | +namespace App\Models; | |
4 | + | |
5 | +use Illuminate\Database\Eloquent\Factories\HasFactory; | |
6 | +use Illuminate\Database\Eloquent\Model; | |
7 | + | |
8 | +class Group_works extends Model | |
9 | +{ | |
10 | + use HasFactory; | |
11 | + | |
12 | + protected $table = 'group_works'; | |
13 | + | |
14 | + protected $fillable = [ | |
15 | + 'group_user_id', | |
16 | + 'user_id', | |
17 | + ]; | |
18 | + | |
19 | + /* | |
20 | + * Связь Модели Группы (Group_user) с Модели Юзеры (User) | |
21 | + многие-к-одному | |
22 | + */ | |
23 | + public function user() { | |
24 | + return $this->belongsTo(User::class, 'user_id'); | |
25 | + } | |
26 | + | |
27 | + /* | |
28 | + * Связь Модели Группы (Group_user) с Модели Юзеры (User) | |
29 | + многие-к-одному | |
30 | + */ | |
31 | + public function group() { | |
32 | + return $this->belongsTo(Group_user::class, 'group_user_id'); | |
33 | + } | |
34 | + | |
35 | +} |
app/Models/Job_title.php
... | ... | @@ -9,10 +9,19 @@ class Job_title extends Model |
9 | 9 | { |
10 | 10 | use HasFactory; |
11 | 11 | |
12 | + protected $fillable = [ | |
13 | + 'name', | |
14 | + 'is_remove', | |
15 | + 'parent_id', | |
16 | + ]; | |
12 | 17 | /* |
13 | 18 | * Связь модели Вакансии (Ad_employer) с моделью Должности (Job_title) |
14 | 19 | */ |
15 | 20 | public function Ads() { |
16 | 21 | return $this->belongsToMany(Ad_employer::class, 'ad_jobs'); |
17 | 22 | } |
23 | + | |
24 | + public function scopeActive($query) { | |
25 | + return $query->where('is_remove', '=', '0'); | |
26 | + } | |
18 | 27 | } |
app/Models/User.php
... | ... | @@ -71,11 +71,12 @@ class User extends Authenticatable |
71 | 71 | } |
72 | 72 | |
73 | 73 | /* |
74 | - * Связь Пользователей системы с группами юзеров | |
74 | + * Связь Модели Пользователей(Users) с Группами (Group_users) | |
75 | 75 | * users - group_users |
76 | - */ | |
77 | - public function groups() { | |
78 | - return $this->hasMany(Group_user::class); | |
76 | + многие-ко-многим | |
77 | + */ | |
78 | + public function ingroup() { | |
79 | + return $this->belongsToMany(Group_user::class, 'group_works'); | |
79 | 80 | } |
80 | 81 | |
81 | 82 | /* |
... | ... | @@ -94,5 +95,16 @@ class User extends Authenticatable |
94 | 95 | return $this->hasMany(Static_worker::class); |
95 | 96 | } |
96 | 97 | |
98 | + /* | |
99 | + * Связь модели Юзеры (users) с моделью Группы пользователей (Group_works) | |
100 | + один-ко-многим | |
101 | + */ | |
102 | + public function peoples() { | |
103 | + return $this->hasMany(Group_works::class); | |
104 | + } | |
105 | + | |
106 | + public function scopeActive($query) { | |
107 | + return $query->where('is_remove', '=', '0'); | |
108 | + } | |
97 | 109 | |
98 | 110 | } |
app/Models/Worker.php
... | ... | @@ -39,6 +39,9 @@ class Worker extends Model |
39 | 39 | 'text', |
40 | 40 | 'address', |
41 | 41 | 'city', |
42 | + 'coord', | |
43 | + 'file', | |
44 | + 'is_remove', | |
42 | 45 | ]; |
43 | 46 | |
44 | 47 | /* |
... | ... | @@ -47,4 +50,8 @@ class Worker extends Model |
47 | 50 | public function users() { |
48 | 51 | return $this->belongsTo(User::class, 'user_id'); |
49 | 52 | } |
53 | + | |
54 | + public function scopeActive($query) { | |
55 | + return $query->where('is_remove', '=', '0'); | |
56 | + } | |
50 | 57 | } |
database/migrations/2023_09_07_134401_alter_group_users_table.php
... | ... | @@ -0,0 +1,32 @@ |
1 | +<?php | |
2 | + | |
3 | +use Illuminate\Database\Migrations\Migration; | |
4 | +use Illuminate\Database\Schema\Blueprint; | |
5 | +use Illuminate\Support\Facades\Schema; | |
6 | + | |
7 | +return new class extends Migration | |
8 | +{ | |
9 | + /** | |
10 | + * Run the migrations. | |
11 | + * | |
12 | + * @return void | |
13 | + */ | |
14 | + public function up() | |
15 | + { | |
16 | + Schema::table('group_users', function (Blueprint $table) { | |
17 | + $table->boolean('is_remove')->default(false); | |
18 | + }); | |
19 | + } | |
20 | + | |
21 | + /** | |
22 | + * Reverse the migrations. | |
23 | + * | |
24 | + * @return void | |
25 | + */ | |
26 | + public function down() | |
27 | + { | |
28 | + Schema::table('group_users', function (Blueprint $table) { | |
29 | + $table->dropColumn('is_remove'); | |
30 | + }); | |
31 | + } | |
32 | +}; |
resources/views/admin/answers/index.blade.php
... | ... | @@ -0,0 +1,130 @@ |
1 | +@extends('layout.admin', ['title' => 'Админка - Отзывы о работодателях']) | |
2 | + | |
3 | +@section('script') | |
4 | + <script> | |
5 | + $(document).ready(function() { | |
6 | + $(document).on('click', '.checkban', function () { | |
7 | + var this_ = $(this); | |
8 | + var value = this_.val(); | |
9 | + var ajax_block = $('#ajax_block'); | |
10 | + var bool = 0; | |
11 | + | |
12 | + if(this.checked){ | |
13 | + bool = 1; | |
14 | + } else { | |
15 | + bool = 0; | |
16 | + } | |
17 | + var str ="id=" + value + "&is_moderate=" + bool; | |
18 | + console.log(str); | |
19 | + $.ajax({ | |
20 | + type: "GET", | |
21 | + url: "{{ url()->full()}}", | |
22 | + data: str, | |
23 | + success: function (data) { | |
24 | + console.log('Обновление таблицы пользователей '); | |
25 | + //data = JSON.parse(data); | |
26 | + //console.log(data); | |
27 | + ajax_block.html(data); | |
28 | + }, | |
29 | + headers: { | |
30 | + 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') | |
31 | + }, | |
32 | + error: function (data) { | |
33 | + console.log('Error: ' + data); | |
34 | + } | |
35 | + }); | |
36 | + }); | |
37 | + | |
38 | + }); | |
39 | + </script> | |
40 | +@endsection | |
41 | + | |
42 | +@section('search') | |
43 | + <!--<div class="absolute inset-y-0 flex items-center pl-2"> | |
44 | + <svg | |
45 | + class="w-4 h-4" | |
46 | + aria-hidden="true" | |
47 | + fill="currentColor" | |
48 | + viewBox="0 0 20 20" | |
49 | + > | |
50 | + <path | |
51 | + fill-rule="evenodd" | |
52 | + d="M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z" | |
53 | + clip-rule="evenodd" | |
54 | + ></path> | |
55 | + </svg> | |
56 | + </div> | |
57 | + <form action="" method="POST"> | |
58 | + <div style="float:left;"><input | |
59 | + class="w-full pl-8 pr-2 text-sm text-gray-700 placeholder-gray-600 bg-gray-100 border-0 rounded-md dark:placeholder-gray-500 dark:focus:shadow-outline-gray dark:focus:placeholder-gray-600 dark:bg-gray-700 dark:text-gray-200 focus:placeholder-gray-500 focus:bg-white focus:border-purple-300 focus:outline-none focus:shadow-outline-purple form-input" | |
60 | + style="width: 400px" | |
61 | + type="text" | |
62 | + placeholder="Искать..." | |
63 | + aria-label="Search" | |
64 | + /></div> | |
65 | + <div style="float: left"> | |
66 | + <button type="submit" class="px-3 py-1 rounded-md focus:outline-none focus:shadow-outline-purple">Искать</button> | |
67 | + </div> | |
68 | + </form>--> | |
69 | +@endsection | |
70 | + | |
71 | +@section('content') | |
72 | + <style> | |
73 | + .col { | |
74 | + width: 250px; /* Ширина блока */ | |
75 | + word-wrap: break-word; /* Перенос слов */ | |
76 | + word-break: break-all; | |
77 | + } | |
78 | + </style> | |
79 | + <div class="w-full overflow-hidden rounded-lg shadow-xs" id="ajax_block"> | |
80 | + <div class="w-full overflow-x-auto"> | |
81 | + <table class="w-full whitespace-no-wrap"> | |
82 | + <thead> | |
83 | + <tr | |
84 | + class="text-xs font-semibold tracking-wide text-left text-gray-500 uppercase border-b dark:border-gray-700 bg-gray-50 dark:text-gray-400 dark:bg-gray-800" | |
85 | + > | |
86 | + <th class="px-4 py-3">№</th> | |
87 | + <th class="px-4 py-3">Название компании</th> | |
88 | + <th class="px-4 py-3">Комментатор</th> | |
89 | + <th class="px-4 py-3">Заголовок/Текст</th> | |
90 | + <th class="px-4 py-3">Дата коммента</th> | |
91 | + <th class="px-4 py-3">Разрешить</th> | |
92 | + </tr> | |
93 | + </thead> | |
94 | + <tbody class="bg-white divide-y dark:divide-gray-700 dark:bg-gray-800"> | |
95 | + @foreach($answers as $answer) | |
96 | + <tr class="text-gray-700 dark:text-gray-400"> | |
97 | + <td class="px-4 py-3"> | |
98 | + {{$answer->id}} | |
99 | + </td> | |
100 | + <td class="px-4 py-3"> | |
101 | + {{$answer->employer->name_company}} | |
102 | + </td> | |
103 | + <td class="px-4 py-3"> | |
104 | + {{$answer->user->name}} | |
105 | + </td> | |
106 | + <td class="px-4 py-3 col" > | |
107 | + <!--<div class="flex items-center text-sm"> | |
108 | + <div >--> | |
109 | + <p class="font-semibold">{{$answer->title}}</p> | |
110 | + <textarea style="width:250px; height: 100px;" readonly="readonly" class="text-xs text-gray-600 dark:text-gray-400">{{ $answer->text }}</textarea> | |
111 | + <!--</div> | |
112 | + </div>--> | |
113 | + </td> | |
114 | + <td class="px-4 py-3 text-sm"> | |
115 | + {{ $answer->created_at }} | |
116 | + </td> | |
117 | + <td class="px-4 py-3 text-sm"> | |
118 | + <input type="checkbox" class="checkban" value="{{$answer->id}}" name="moderate_{{$answer->id}}" {{ ($answer->is_moderate) ? "checked" : "" }}/> | |
119 | + </td> | |
120 | + </tr> | |
121 | + @endforeach | |
122 | + </tbody> | |
123 | + </table> | |
124 | + </div> | |
125 | + | |
126 | + <div class="grid px-4 py-3 text-xs font-semibold tracking-wide text-gray-500 uppercase border-t dark:border-gray-700 bg-gray-50 sm:grid-cols-9 dark:text-gray-400 dark:bg-gray-800"> | |
127 | + <?=$answers->appends($_GET)->links('admin.pagginate'); ?> | |
128 | + </div> | |
129 | + </div> | |
130 | +@endsection |
resources/views/admin/answers/index_ajax.blade.php
... | ... | @@ -0,0 +1,49 @@ |
1 | +<div class="w-full overflow-x-auto"> | |
2 | + <table class="w-full whitespace-no-wrap"> | |
3 | + <thead> | |
4 | + <tr | |
5 | + class="text-xs font-semibold tracking-wide text-left text-gray-500 uppercase border-b dark:border-gray-700 bg-gray-50 dark:text-gray-400 dark:bg-gray-800" | |
6 | + > | |
7 | + <th class="px-4 py-3">№</th> | |
8 | + <th class="px-4 py-3">Название компании</th> | |
9 | + <th class="px-4 py-3">Комментатор</th> | |
10 | + <th class="px-4 py-3">Заголовок/Текст</th> | |
11 | + <th class="px-4 py-3">Дата коммента</th> | |
12 | + <th class="px-4 py-3">Разрешить</th> | |
13 | + </tr> | |
14 | + </thead> | |
15 | + <tbody class="bg-white divide-y dark:divide-gray-700 dark:bg-gray-800"> | |
16 | + @foreach($answers as $answer) | |
17 | + <tr class="text-gray-700 dark:text-gray-400"> | |
18 | + <td class="px-4 py-3"> | |
19 | + {{$answer->id}} | |
20 | + </td> | |
21 | + <td class="px-4 py-3"> | |
22 | + {{$answer->employer->name_company}} | |
23 | + </td> | |
24 | + <td class="px-4 py-3"> | |
25 | + {{$answer->user->name}} | |
26 | + </td> | |
27 | + <td class="px-4 py-3 col" > | |
28 | + <!--<div class="flex items-center text-sm"> | |
29 | + <div >--> | |
30 | + <p class="font-semibold">{{$answer->title}}</p> | |
31 | + <textarea style="width:250px; height: 100px;" readonly="readonly" class="text-xs text-gray-600 dark:text-gray-400">{{ $answer->text }}</textarea> | |
32 | + <!--</div> | |
33 | + </div>--> | |
34 | + </td> | |
35 | + <td class="px-4 py-3 text-sm"> | |
36 | + {{ $answer->created_at }} | |
37 | + </td> | |
38 | + <td class="px-4 py-3 text-sm"> | |
39 | + <input type="checkbox" class="checkban" value="{{$answer->id}}" name="moderate_{{$answer->id}}" {{ ($answer->is_moderate) ? "checked" : "" }}/> | |
40 | + </td> | |
41 | + </tr> | |
42 | + @endforeach | |
43 | + </tbody> | |
44 | + </table> | |
45 | +</div> | |
46 | + | |
47 | +<div class="grid px-4 py-3 text-xs font-semibold tracking-wide text-gray-500 uppercase border-t dark:border-gray-700 bg-gray-50 sm:grid-cols-9 dark:text-gray-400 dark:bg-gray-800"> | |
48 | + <?=$answers->appends($_GET)->links('admin.pagginate'); ?> | |
49 | +</div> |
resources/views/admin/category/index.blade.php
... | ... | @@ -99,12 +99,12 @@ |
99 | 99 | <td class="px-4 py-3"> |
100 | 100 | {{$cat->created_at}} |
101 | 101 | </td> |
102 | - <td class="px-4 py-3 text-sm"> | |
102 | + <td class="px-4 py-3 text-sm_"> | |
103 | 103 | <form action="{{ route('admin.categories.destroy', ['category' => $cat->id]) }}" method="POST"> |
104 | 104 | <a href="{{ route('admin.categories.edit', ['category' => $cat->id]) }}">Изменить</a> | |
105 | 105 | @csrf |
106 | 106 | @method('DELETE') |
107 | - <input class=" btn-danger" type="submit" value="Удалить"> | |
107 | + <input class="btn btn-danger" type="submit" value="Удалить"/> | |
108 | 108 | </form> |
109 | 109 | </td> |
110 | 110 | </tr> |
resources/views/admin/groups/form.blade.php
... | ... | @@ -11,7 +11,6 @@ |
11 | 11 | </span> |
12 | 12 | @enderror |
13 | 13 | </label><br> |
14 | - | |
15 | 14 | <input type="hidden" name="user_id" id="user_id" value="{{ $editor }}"/> |
16 | 15 | |
17 | 16 | <div class="flex flex-col flex-wrap mb-4 space-y-4 md:flex-row md:items-end md:space-x-4"> |
... | ... | @@ -21,5 +20,38 @@ |
21 | 20 | </button> |
22 | 21 | </div> |
23 | 22 | </div> |
23 | + | |
24 | + <label class="block text-sm"> | |
25 | + <span class="text-gray-700 dark:text-gray-400">Пользователи системы</span> | |
26 | + </label> | |
27 | + <table class="w-full whitespace-no-wrap"> | |
28 | + <thead> | |
29 | + <tr | |
30 | + class="text-xs font-semibold tracking-wide text-left text-gray-500 uppercase border-b dark:border-gray-700 bg-gray-50 dark:text-gray-400 dark:bg-gray-800" | |
31 | + > | |
32 | + <th class="px-4 py-3">№</th> | |
33 | + <th class="px-4 py-3">Имя пользователя</th> | |
34 | + <th class="px-4 py-3">Добавленные в группу</th> | |
35 | + </tr> | |
36 | + </thead> | |
37 | + <tbody class="bg-white divide-y dark:divide-gray-700 dark:bg-gray-800"> | |
38 | + @foreach($users as $user) | |
39 | + <tr class="text-gray-700 dark:text-gray-400"> | |
40 | + <td class="px-4 py-3"> | |
41 | + {{$user->id}} | |
42 | + </td> | |
43 | + <td class="px-4 py-3"> | |
44 | + {{$user->name}} | |
45 | + </td> | |
46 | + <td class="px-4 py-3"> | |
47 | + <input type="checkbox" id="user{{$user->id}}" name="usergroup[]" value="{{$user->id}}" <?php //if ($user->groups->group_user_id == $group->id) {?>checked<?//}?>/> | |
48 | + <pre><? //print_r($user->ingroup->id);?></pre> | |
49 | + </td> | |
50 | + </tr> | |
51 | + @endforeach | |
52 | + </tbody> | |
53 | + </table> | |
54 | + | |
55 | + | |
24 | 56 | </div> |
25 | 57 |
resources/views/admin/groups/index.blade.php
... | ... | @@ -102,8 +102,13 @@ |
102 | 102 | <td class="px-4 py-3 text-sm"> |
103 | 103 | {{ $group->created_at }} |
104 | 104 | </td> |
105 | - <td class="px-4 py-3 text-sm"> | |
106 | - <a href="{{ route('admin.edit-group', ['group' => $group->id]) }}">Изменить</a> | |
105 | + <td class="px-4 py-3 text-sm_"> | |
106 | + <form action="{{ route('admin.delete-group', ['group' => $group->id]) }}" method="POST"> | |
107 | + <a href="{{ route('admin.edit-group', ['group' => $group->id]) }}">Изменить</a> | | |
108 | + @csrf | |
109 | + @method('DELETE') | |
110 | + <input class="btn btn-danger" type="submit" value="Удалить"/> | |
111 | + </form> | |
107 | 112 | </td> |
108 | 113 | </tr> |
109 | 114 | @endforeach |
resources/views/admin/static/index.blade.php
... | ... | @@ -0,0 +1,65 @@ |
1 | +@extends('layout.admin', ['title' => 'Админка - Страница статистики']) | |
2 | + | |
3 | +@section('content') | |
4 | + | |
5 | + <!-- Таблицы --> | |
6 | + <div class="w-full overflow-hidden rounded-lg shadow-xs"> | |
7 | + <div class="w-full overflow-x-auto"> | |
8 | + <table class="w-full whitespace-no-wrap"> | |
9 | + <thead> | |
10 | + <tr | |
11 | + class="text-xs font-semibold tracking-wide text-left text-gray-500 uppercase border-b dark:border-gray-700 bg-gray-50 dark:text-gray-400 dark:bg-gray-800" | |
12 | + > | |
13 | + <th class="px-4 py-3">Название</th> | |
14 | + <th class="px-4 py-3">Ссылка</th> | |
15 | + </tr> | |
16 | + </thead> | |
17 | + <tbody class="bg-white divide-y dark:divide-gray-700 dark:bg-gray-800"> | |
18 | + <tr class="text-gray-700 dark:text-gray-400"> | |
19 | + <td class="px-4 py-3"> | |
20 | + <div class="flex items-center text-sm"> | |
21 | + <div class="relative hidden w-8 h-8 mr-3 rounded-full md:block"> | |
22 | + <div | |
23 | + class="absolute inset-0 rounded-full shadow-inner" | |
24 | + aria-hidden="true" | |
25 | + ></div> | |
26 | + </div> | |
27 | + <div> | |
28 | + <p class="font-semibold">Статистика пользователей</p> | |
29 | + <p class="text-xs text-gray-600 dark:text-gray-400"> | |
30 | + Информация о просмотрах и сообщениях пользователей разбитая по месяцам | |
31 | + </p> | |
32 | + </div> | |
33 | + </div> | |
34 | + </td> | |
35 | + <td class="px-4 py-3 text-sm"> | |
36 | + <a href="{{ route('admin.static-workers') }}">Ссылка</a> | |
37 | + </td> | |
38 | + </tr> | |
39 | + <tr class="text-gray-700 dark:text-gray-400"> | |
40 | + <td class="px-4 py-3"> | |
41 | + <div class="flex items-center text-sm"> | |
42 | + <div class="relative hidden w-8 h-8 mr-3 rounded-full md:block"> | |
43 | + <div | |
44 | + class="absolute inset-0 rounded-full shadow-inner" | |
45 | + aria-hidden="true" | |
46 | + ></div> | |
47 | + </div> | |
48 | + <div> | |
49 | + <p class="font-semibold">Статистика вакансий</p> | |
50 | + <p class="text-xs text-gray-600 dark:text-gray-400"> | |
51 | + Информация о просмотрах и отликах о вакансиях (по месяцам) | |
52 | + </p> | |
53 | + </div> | |
54 | + </div> | |
55 | + </td> | |
56 | + <td class="px-4 py-3 text-sm"> | |
57 | + <a href="{{ route('admin.static-ads') }}">Ссылка</a> | |
58 | + </td> | |
59 | + </tr> | |
60 | + | |
61 | + </tbody> | |
62 | + </table> | |
63 | + </div> | |
64 | + </div> | |
65 | +@endsection |
resources/views/admin/users/roles/index.blade.php
... | ... | @@ -0,0 +1,238 @@ |
1 | +@extends('layout.admin', ['title' => 'Роли пользователей']) | |
2 | + | |
3 | +@section('script') | |
4 | + <script> | |
5 | + $(document).ready(function() { | |
6 | + $(document).on('click', '.check_click', function () { | |
7 | + var this_ = $(this); | |
8 | + var value = this_.val(); | |
9 | + var field = this_.attr('data-field'); | |
10 | + var ajax_block = $('#ajax_block'); | |
11 | + var bool = 0; | |
12 | + var str_get = ''; | |
13 | + | |
14 | + if(this.checked){ | |
15 | + bool = 1; | |
16 | + } else { | |
17 | + bool = 0; | |
18 | + } | |
19 | + console.log(field); | |
20 | + str_get = "id=" + value + "&" + field + "=" + bool; | |
21 | + console.log(str_get); | |
22 | + | |
23 | + $.ajax({ | |
24 | + type: "GET", | |
25 | + url: "{{ url()->full()}}", | |
26 | + data: str_get, | |
27 | + success: function (data) { | |
28 | + console.log('Обновление таблицы пользователей '); | |
29 | + //data = JSON.parse(data); | |
30 | + //console.log(data); | |
31 | + ajax_block.html(data); | |
32 | + }, | |
33 | + headers: { | |
34 | + 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') | |
35 | + }, | |
36 | + error: function (data) { | |
37 | + console.log('Error: ' + data); | |
38 | + } | |
39 | + }); | |
40 | + }); | |
41 | + }); | |
42 | + </script> | |
43 | +@endsection | |
44 | + | |
45 | +@section('search') | |
46 | + <div class="absolute inset-y-0 flex items-center pl-2"> | |
47 | + <svg | |
48 | + class="w-4 h-4" | |
49 | + aria-hidden="true" | |
50 | + fill="currentColor" | |
51 | + viewBox="0 0 20 20" | |
52 | + > | |
53 | + <path | |
54 | + fill-rule="evenodd" | |
55 | + d="M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z" | |
56 | + clip-rule="evenodd" | |
57 | + ></path> | |
58 | + </svg> | |
59 | + </div> | |
60 | + <form action="" method="POST"> | |
61 | + <div style="float:left;"><input | |
62 | + class="w-full pl-8 pr-2 text-sm text-gray-700 placeholder-gray-600 bg-gray-100 border-0 rounded-md dark:placeholder-gray-500 dark:focus:shadow-outline-gray dark:focus:placeholder-gray-600 dark:bg-gray-700 dark:text-gray-200 focus:placeholder-gray-500 focus:bg-white focus:border-purple-300 focus:outline-none focus:shadow-outline-purple form-input" | |
63 | + style="width: 400px" | |
64 | + type="text" | |
65 | + placeholder="Искать..." | |
66 | + aria-label="Search" | |
67 | + /></div> | |
68 | + <div style="float: left"> | |
69 | + <button type="submit" class="px-3 py-1 rounded-md focus:outline-none focus:shadow-outline-purple">Искать</button> | |
70 | + </div> | |
71 | + </form> | |
72 | +@endsection | |
73 | + | |
74 | +@section('content') | |
75 | + <div class="w-full overflow-hidden rounded-lg shadow-xs" id="ajax_block"> | |
76 | + <div class="w-full overflow-x-auto"> | |
77 | + <table class="w-full whitespace-no-wrap"> | |
78 | + <thead> | |
79 | + <tr | |
80 | + class="text-xs font-semibold tracking-wide text-left text-gray-500 uppercase border-b dark:border-gray-700 bg-gray-50 dark:text-gray-400 dark:bg-gray-800" | |
81 | + > | |
82 | + <th class="px-4 py-3">№</th> | |
83 | + <th class="px-4 py-3">Имя</th> | |
84 | + <th class="px-4 py-3">Email/логин</th> | |
85 | + <th class="px-4 py-3">Просмотр резюме</th> | |
86 | + <th class="px-4 py-3">Отправка сообщений</th> | |
87 | + <th class="px-4 py-3">Публикация вакансий</th> | |
88 | + <th class="px-4 py-3">Админ</th> | |
89 | + <!--<th class="px-4 py-3">Дата регистрации</th>--> | |
90 | + </tr> | |
91 | + </thead> | |
92 | + <tbody class="bg-white divide-y dark:divide-gray-700 dark:bg-gray-800"> | |
93 | + @foreach($users as $user) | |
94 | + <tr class="text-gray-700 dark:text-gray-400"> | |
95 | + <td class="px-4 py-3"> | |
96 | + {{$user->id}} | |
97 | + </td> | |
98 | + <td class="px-4 py-3"> | |
99 | + {{ $user->name }} | |
100 | + </td> | |
101 | + <td class="px-4 py-3 text-sm"> | |
102 | + {{ $user->email }} | |
103 | + </td> | |
104 | + <td class="px-4 py-3 text-sm"> | |
105 | + <input type="checkbox" class="check_click" value="{{$user->id}}" data-field="is_lookin" name="lookin_{{$user->id}}" {{ ($user->is_lookin) ? "checked" : "" }}/> | |
106 | + </td> | |
107 | + | |
108 | + <td class="px-4 py-3 text-sm"> | |
109 | + <input type="checkbox" class="check_click" value="{{$user->id}}" data-field="is_message" name="message_{{$user->id}}" {{ ($user->is_message) ? "checked" : "" }}/> | |
110 | + </td> | |
111 | + | |
112 | + <td class="px-4 py-3 text-sm"> | |
113 | + <input type="checkbox" class="check_click" value="{{$user->id}}" data-field="is_public" name="public_{{$user->id}}" {{ ($user->is_public) ? "checked" : "" }}/> | |
114 | + </td> | |
115 | + | |
116 | + <td class="px-4 py-3 text-sm"> | |
117 | + @if ($user->id > 1) | |
118 | + <input type="checkbox" class="check_click" value="{{$user->id}}" data-field="admin" name="admin_{{$user->id}}" {{ ($user->admin) ? "checked" : "" }}/> | |
119 | + @endif | |
120 | + </td> | |
121 | + | |
122 | + <!--<td class="px-4 py-3 text-sm"> | |
123 | + {{ $user->created_at }} | |
124 | + </td>--> | |
125 | + </tr> | |
126 | + @endforeach | |
127 | + </tbody> | |
128 | + </table> | |
129 | + </div> | |
130 | + | |
131 | + <div class="grid px-4 py-3 text-xs font-semibold tracking-wide text-gray-500 uppercase border-t dark:border-gray-700 bg-gray-50 sm:grid-cols-9 dark:text-gray-400 dark:bg-gray-800"> | |
132 | + <?//=$users->appends($_GET)->links('admin.pagginate'); ?> | |
133 | + <?=$users->links('admin.pagginate'); ?> | |
134 | + </div> | |
135 | + | |
136 | + | |
137 | + <!--<div | |
138 | + class="grid px-4 py-3 text-xs font-semibold tracking-wide text-gray-500 uppercase border-t dark:border-gray-700 bg-gray-50 sm:grid-cols-9 dark:text-gray-400 dark:bg-gray-800" | |
139 | + > | |
140 | + <span class="flex items-center col-span-3"> | |
141 | + Showing 21-30 of 100 | |
142 | + </span> | |
143 | + <span class="col-span-2"></span> | |
144 | + | |
145 | + <span class="flex col-span-4 mt-2 sm:mt-auto sm:justify-end"> | |
146 | + <nav aria-label="Table navigation"> | |
147 | + <ul class="inline-flex items-center"> | |
148 | + <li> | |
149 | + <button | |
150 | + class="px-3 py-1 rounded-md rounded-l-lg focus:outline-none focus:shadow-outline-purple" | |
151 | + aria-label="Previous" | |
152 | + > | |
153 | + <svg | |
154 | + aria-hidden="true" | |
155 | + class="w-4 h-4 fill-current" | |
156 | + viewBox="0 0 20 20" | |
157 | + > | |
158 | + <path | |
159 | + d="M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z" | |
160 | + clip-rule="evenodd" | |
161 | + fill-rule="evenodd" | |
162 | + ></path> | |
163 | + </svg> | |
164 | + </button> | |
165 | + </li> | |
166 | + <li> | |
167 | + <button | |
168 | + class="px-3 py-1 rounded-md focus:outline-none focus:shadow-outline-purple" | |
169 | + > | |
170 | + 1 | |
171 | + </button> | |
172 | + </li> | |
173 | + <li> | |
174 | + <button | |
175 | + class="px-3 py-1 rounded-md focus:outline-none focus:shadow-outline-purple" | |
176 | + > | |
177 | + 2 | |
178 | + </button> | |
179 | + </li> | |
180 | + <li> | |
181 | + <button | |
182 | + class="px-3 py-1 text-white transition-colors duration-150 bg-purple-600 border border-r-0 border-purple-600 rounded-md focus:outline-none focus:shadow-outline-purple" | |
183 | + > | |
184 | + 3 | |
185 | + </button> | |
186 | + </li> | |
187 | + <li> | |
188 | + <button | |
189 | + class="px-3 py-1 rounded-md focus:outline-none focus:shadow-outline-purple" | |
190 | + > | |
191 | + 4 | |
192 | + </button> | |
193 | + </li> | |
194 | + <li> | |
195 | + <span class="px-3 py-1">...</span> | |
196 | + </li> | |
197 | + <li> | |
198 | + <button | |
199 | + class="px-3 py-1 rounded-md focus:outline-none focus:shadow-outline-purple" | |
200 | + > | |
201 | + 8 | |
202 | + </button> | |
203 | + </li> | |
204 | + <li> | |
205 | + <button | |
206 | + class="px-3 py-1 rounded-md focus:outline-none focus:shadow-outline-purple" | |
207 | + > | |
208 | + 9 | |
209 | + </button> | |
210 | + </li> | |
211 | + <li> | |
212 | + <button | |
213 | + class="px-3 py-1 rounded-md rounded-r-lg focus:outline-none focus:shadow-outline-purple" | |
214 | + aria-label="Next" | |
215 | + > | |
216 | + <svg | |
217 | + class="w-4 h-4 fill-current" | |
218 | + aria-hidden="true" | |
219 | + viewBox="0 0 20 20" | |
220 | + > | |
221 | + <path | |
222 | + d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" | |
223 | + clip-rule="evenodd" | |
224 | + fill-rule="evenodd" | |
225 | + ></path> | |
226 | + </svg> | |
227 | + </button> | |
228 | + </li> | |
229 | + </ul> | |
230 | + </nav> | |
231 | + </span> | |
232 | + </div>--> | |
233 | + </div> | |
234 | + | |
235 | + <?//=$users->appends($_GET)->links('catalogs.paginate'); ?> | |
236 | + | |
237 | + | |
238 | +@endsection |
resources/views/admin/users/roles/index_ajax.blade.php
... | ... | @@ -0,0 +1,59 @@ |
1 | + <div class="w-full overflow-x-auto"> | |
2 | + <table class="w-full whitespace-no-wrap"> | |
3 | + <thead> | |
4 | + <tr | |
5 | + class="text-xs font-semibold tracking-wide text-left text-gray-500 uppercase border-b dark:border-gray-700 bg-gray-50 dark:text-gray-400 dark:bg-gray-800" | |
6 | + > | |
7 | + <th class="px-4 py-3">№</th> | |
8 | + <th class="px-4 py-3">Имя</th> | |
9 | + <th class="px-4 py-3">Email/логин</th> | |
10 | + <th class="px-4 py-3">Просмотр резюме</th> | |
11 | + <th class="px-4 py-3">Отправка сообщений</th> | |
12 | + <th class="px-4 py-3">Публикация вакансий</th> | |
13 | + <th class="px-4 py-3">Админ</th> | |
14 | + <!--<th class="px-4 py-3">Дата регистрации</th>--> | |
15 | + </tr> | |
16 | + </thead> | |
17 | + <tbody class="bg-white divide-y dark:divide-gray-700 dark:bg-gray-800"> | |
18 | + @foreach($users as $user) | |
19 | + <tr class="text-gray-700 dark:text-gray-400"> | |
20 | + <td class="px-4 py-3"> | |
21 | + {{$user->id}} | |
22 | + </td> | |
23 | + <td class="px-4 py-3"> | |
24 | + {{ $user->name }} | |
25 | + </td> | |
26 | + <td class="px-4 py-3 text-sm"> | |
27 | + {{ $user->email }} | |
28 | + </td> | |
29 | + <td class="px-4 py-3 text-sm"> | |
30 | + <input type="checkbox" class="check_click" value="{{$user->id}}" data-field="is_lookin" name="lookin_{{$user->id}}" {{ ($user->is_lookin) ? "checked" : "" }}/> | |
31 | + </td> | |
32 | + | |
33 | + <td class="px-4 py-3 text-sm"> | |
34 | + <input type="checkbox" class="check_click" value="{{$user->id}}" data-field="is_message" name="message_{{$user->id}}" {{ ($user->is_message) ? "checked" : "" }}/> | |
35 | + </td> | |
36 | + | |
37 | + <td class="px-4 py-3 text-sm"> | |
38 | + <input type="checkbox" class="check_click" value="{{$user->id}}" data-field="is_public" name="public_{{$user->id}}" {{ ($user->is_public) ? "checked" : "" }}/> | |
39 | + </td> | |
40 | + | |
41 | + <td class="px-4 py-3 text-sm"> | |
42 | + @if ($user->id > 1) | |
43 | + <input type="checkbox" class="check_click" value="{{$user->id}}" data-field="admin" name="admin_{{$user->id}}" {{ ($user->admin) ? "checked" : "" }}/> | |
44 | + @endif | |
45 | + </td> | |
46 | + | |
47 | + <!--<td class="px-4 py-3 text-sm"> | |
48 | + {{ $user->created_at }} | |
49 | + </td>--> | |
50 | + </tr> | |
51 | + @endforeach | |
52 | + </tbody> | |
53 | + </table> | |
54 | + </div> | |
55 | + | |
56 | + <div class="grid px-4 py-3 text-xs font-semibold tracking-wide text-gray-500 uppercase border-t dark:border-gray-700 bg-gray-50 sm:grid-cols-9 dark:text-gray-400 dark:bg-gray-800"> | |
57 | + <?//=$users->appends($_GET)->links('admin.pagginate'); ?> | |
58 | + <?=$users->links('admin.pagginate'); ?> | |
59 | + </div> |
routes/web.php
... | ... | @@ -149,6 +149,8 @@ Route::group([ |
149 | 149 | Route::get('groups/edit/{group}', [GroupsController::class, 'edit'])->name('edit-group'); |
150 | 150 | // кабинет - сохранение редактированной формы группы пользователей |
151 | 151 | Route::post('groups/edit/{group}', [GroupsController::class, 'update'])->name('update-group'); |
152 | + // кабинет - удаление группы пользователей | |
153 | + Route::delete('groups/delete/{group}', [GroupsController::class, 'destroy'])->name('delete-group'); | |
152 | 154 | |
153 | 155 | // кабинет - список админов |
154 | 156 | Route::get('group-admin', [AdminController::class, 'index'])->name('group-admin'); |