diff --git a/app/Http/Controllers/Admin/CategoryController.php b/app/Http/Controllers/Admin/CategoryController.php
index c98d2e6..8c7d363 100644
--- a/app/Http/Controllers/Admin/CategoryController.php
+++ b/app/Http/Controllers/Admin/CategoryController.php
@@ -18,7 +18,7 @@ class CategoryController extends Controller
*/
public function index()
{
- $category = Category::query()->paginate(15);
+ $category = Category::query()->active()->paginate(15);
return view('admin.category.index', compact('category'));
}
@@ -87,9 +87,11 @@ class CategoryController extends Controller
*/
public function destroy(Category $category)
{
- if (Auth::user()->id == 1) {
+ /*if (Auth::user()->id == 1) {
$category->delete();
- }
+ } else {*/
+ $category->update(['is_remove' => 1]);
+ //}
return redirect()->route('admin.categories.index');
}
}
diff --git a/app/Http/Controllers/Admin/EmployersController.php b/app/Http/Controllers/Admin/EmployersController.php
index edb589f..a3dfb36 100644
--- a/app/Http/Controllers/Admin/EmployersController.php
+++ b/app/Http/Controllers/Admin/EmployersController.php
@@ -3,6 +3,7 @@
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
+use App\Models\Answer;
use App\Models\Employer;
use App\Models\User;
use Illuminate\Http\Request;
@@ -89,8 +90,20 @@ class EmployersController extends Controller
}
// кабинет - отзывы о работодателе для модерации
- public function answers() {
- return;
+ public function answers(Request $request) {
+ if ($request->ajax()) {
+ $user = Answer::find($request->id);
+ $request->offsetUnset('id');
+ $user->update($request->all());
+ }
+
+ $answers = Answer::query()->orderByDesc('id')->paginate(15);
+
+ if ($request->ajax()) {
+ return view('admin.answers.index_ajax', compact('answers'));
+ } else {
+ return view('admin.answers.index', compact('answers'));
+ }
}
// кабинет - статистика вакансий работодателя
diff --git a/app/Http/Controllers/Admin/GroupsController.php b/app/Http/Controllers/Admin/GroupsController.php
index 22f1a5f..e3c17ae 100644
--- a/app/Http/Controllers/Admin/GroupsController.php
+++ b/app/Http/Controllers/Admin/GroupsController.php
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\Group_user;
+use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Validator;
@@ -12,14 +13,15 @@ class GroupsController extends Controller
{
// индексная страница
public function index() {
- $groups = Group_user::query()->paginate(15);
+ $groups = Group_user::query()->active()->paginate(15);
return view('admin.groups.index', compact('groups'));
}
// форма добавления группы
public function add() {
$editor = Auth::user()->id;
- return view('admin.groups.add', compact('editor'));
+ $users = User::query()->get();
+ return view('admin.groups.add', compact('editor', 'users'));
}
// форма сохранения добавленной группы
@@ -46,11 +48,15 @@ class GroupsController extends Controller
// форма редактирования группы
public function edit(Group_user $group, Request $request) {
$editor = Auth::user()->id;
- return view('admin.groups.edit', compact('editor', 'group'));
+ $users = User::query()->get();
+ return view('admin.groups.edit', compact('editor', 'group', 'users'));
}
// форма сохранения редактированной группы
public function update(Group_user $group, Request $request) {
+
+ $params = $request->all();
+ unset($params['usergroup']);
$rules = [
'name_group' => 'required|min:3',
];
@@ -64,9 +70,22 @@ class GroupsController extends Controller
->withErrors($validator);
} else {
$group->update($request->all());
+ $group->ingroup()->sync($request->usergroup);
+ /*if ($request->usergroup->count()) {
+ foreach ($request->usergroup as $us) {
+ Group_works
+ }
+ }*/
+
return redirect()->route('admin.groups')
->with('success', 'Данные были успешно сохранены');
}
return redirect()->route('admin.groups');
}
+
+ public function destroy(Group_user $group) {
+ $group->update(['is_remove' => 1]);
+
+ return redirect()->route('admin.groups');
+ }
}
diff --git a/app/Http/Controllers/Admin/UsersController.php b/app/Http/Controllers/Admin/UsersController.php
index 14e0782..57bbbd3 100644
--- a/app/Http/Controllers/Admin/UsersController.php
+++ b/app/Http/Controllers/Admin/UsersController.php
@@ -27,7 +27,19 @@ class UsersController extends Controller
}
}
- public function roles() {
- return;
+ public function roles(Request $request) {
+ if ($request->ajax()) {
+ $user = User::find($request->id);
+ $request->offsetUnset('id');
+ $user->update($request->all());
+ }
+
+ $users = User::query()->paginate(15);
+
+ if ($request->ajax()) {
+ return view('admin.users.roles.index_ajax', compact('users'));
+ } else {
+ return view('admin.users.roles.index', compact('users'));
+ }
}
}
diff --git a/app/Models/Ad_employer.php b/app/Models/Ad_employer.php
index ca17d8b..2bd9d4d 100644
--- a/app/Models/Ad_employer.php
+++ b/app/Models/Ad_employer.php
@@ -9,6 +9,19 @@ class Ad_employer extends Model
{
use HasFactory;
+ protected $fillable = [
+ 'name',
+ 'telephone',
+ 'email',
+ 'salary',
+ 'category_id',
+ 'text',
+ 'employer_id',
+ 'city',
+ 'sort',
+ 'is_remove',
+ 'active_is',
+ ];
/*
* Связь таблицы employers с таблицей ad_employers
многие-к-одному
@@ -32,4 +45,8 @@ class Ad_employer extends Model
public function response() {
return $this->hasMany(ad_response::class);
}
+
+ public function scopeActive($query) {
+ return $query->where('is_remove', '=', '0');
+ }
}
diff --git a/app/Models/Answer.php b/app/Models/Answer.php
index c2e96b1..d48fd42 100644
--- a/app/Models/Answer.php
+++ b/app/Models/Answer.php
@@ -8,4 +8,32 @@ use Illuminate\Database\Eloquent\Model;
class Answer extends Model
{
use HasFactory;
+
+ protected $fillable = [
+ 'employer_id',
+ 'user_id',
+ 'plus',
+ 'minus',
+ 'rate',
+ 'title',
+ 'text',
+ 'is_moderate',
+ ];
+
+ /*
+ * Связь таблицы employers с таблицей answers
+ многие-к-одному
+ */
+ public function employer() {
+ return $this->belongsTo(Employer::class, 'employer_id');
+ }
+
+ /*
+ * Связь таблицы users с таблицей answers
+ многие-к-одному
+ */
+ public function user() {
+ return $this->belongsTo(User::class, 'user_id');
+ }
+
}
diff --git a/app/Models/Category.php b/app/Models/Category.php
index 846941f..5434c3e 100644
--- a/app/Models/Category.php
+++ b/app/Models/Category.php
@@ -11,5 +11,10 @@ class Category extends Model
protected $fillable = [
'name',
+ 'is_remove'
];
+
+ public function scopeActive($query) {
+ return $query->where('is_remove', '=', '0');
+ }
}
diff --git a/app/Models/Employer.php b/app/Models/Employer.php
index aae29aa..78cc299 100644
--- a/app/Models/Employer.php
+++ b/app/Models/Employer.php
@@ -21,6 +21,12 @@ class Employer extends Model
'address',
'map',
'site',
+ 'coord',
+ 'plus',
+ 'is_remove',
+ 'oficial_status',
+ 'social_is',
+ 'sending_is',
];
/*
@@ -37,5 +43,8 @@ class Employer extends Model
return $this->hasMany(Ad_employer::class);
}
+ public function scopeActive($query) {
+ return $query->where('is_remove', '=', '0');
+ }
}
diff --git a/app/Models/Group_user.php b/app/Models/Group_user.php
index 50bf2c4..4a135c9 100644
--- a/app/Models/Group_user.php
+++ b/app/Models/Group_user.php
@@ -12,6 +12,7 @@ class Group_user extends Model
protected $fillable = [
'name_group',
'user_id',
+ 'is_remove',
];
/*
@@ -30,4 +31,16 @@ class Group_user extends Model
return $this->belongsToMany(User::class, 'group_works');
}
+ /*
+ * Связь модели Группы (Group_users) с моделью Группы пользователей (Group_works)
+ один-ко-многим
+ */
+ public function peoples() {
+ return $this->hasMany(Group_works::class);
+ }
+
+ public function scopeActive($query) {
+ return $query->where('is_remove', '=', '0');
+ }
+
}
diff --git a/app/Models/Group_works.php b/app/Models/Group_works.php
new file mode 100644
index 0000000..a718240
--- /dev/null
+++ b/app/Models/Group_works.php
@@ -0,0 +1,35 @@
+belongsTo(User::class, 'user_id');
+ }
+
+ /*
+ * Связь Модели Группы (Group_user) с Модели Юзеры (User)
+ многие-к-одному
+ */
+ public function group() {
+ return $this->belongsTo(Group_user::class, 'group_user_id');
+ }
+
+}
diff --git a/app/Models/Job_title.php b/app/Models/Job_title.php
index a21dc75..ecf01fb 100644
--- a/app/Models/Job_title.php
+++ b/app/Models/Job_title.php
@@ -9,10 +9,19 @@ class Job_title extends Model
{
use HasFactory;
+ protected $fillable = [
+ 'name',
+ 'is_remove',
+ 'parent_id',
+ ];
/*
* Связь модели Вакансии (Ad_employer) с моделью Должности (Job_title)
*/
public function Ads() {
return $this->belongsToMany(Ad_employer::class, 'ad_jobs');
}
+
+ public function scopeActive($query) {
+ return $query->where('is_remove', '=', '0');
+ }
}
diff --git a/app/Models/User.php b/app/Models/User.php
index 6d5de93..d12dbf4 100644
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -71,11 +71,12 @@ class User extends Authenticatable
}
/*
- * Связь Пользователей системы с группами юзеров
+ * Связь Модели Пользователей(Users) с Группами (Group_users)
* users - group_users
- */
- public function groups() {
- return $this->hasMany(Group_user::class);
+ многие-ко-многим
+ */
+ public function ingroup() {
+ return $this->belongsToMany(Group_user::class, 'group_works');
}
/*
@@ -94,5 +95,16 @@ class User extends Authenticatable
return $this->hasMany(Static_worker::class);
}
+ /*
+ * Связь модели Юзеры (users) с моделью Группы пользователей (Group_works)
+ один-ко-многим
+ */
+ public function peoples() {
+ return $this->hasMany(Group_works::class);
+ }
+
+ public function scopeActive($query) {
+ return $query->where('is_remove', '=', '0');
+ }
}
diff --git a/app/Models/Worker.php b/app/Models/Worker.php
index 564e122..d5ab505 100644
--- a/app/Models/Worker.php
+++ b/app/Models/Worker.php
@@ -39,6 +39,9 @@ class Worker extends Model
'text',
'address',
'city',
+ 'coord',
+ 'file',
+ 'is_remove',
];
/*
@@ -47,4 +50,8 @@ class Worker extends Model
public function users() {
return $this->belongsTo(User::class, 'user_id');
}
+
+ public function scopeActive($query) {
+ return $query->where('is_remove', '=', '0');
+ }
}
diff --git a/database/migrations/2023_09_07_134401_alter_group_users_table.php b/database/migrations/2023_09_07_134401_alter_group_users_table.php
new file mode 100644
index 0000000..b651264
--- /dev/null
+++ b/database/migrations/2023_09_07_134401_alter_group_users_table.php
@@ -0,0 +1,32 @@
+boolean('is_remove')->default(false);
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::table('group_users', function (Blueprint $table) {
+ $table->dropColumn('is_remove');
+ });
+ }
+};
diff --git a/resources/views/admin/answers/index.blade.php b/resources/views/admin/answers/index.blade.php
new file mode 100644
index 0000000..37394f2
--- /dev/null
+++ b/resources/views/admin/answers/index.blade.php
@@ -0,0 +1,130 @@
+@extends('layout.admin', ['title' => 'Админка - Отзывы о работодателях'])
+
+@section('script')
+
+@endsection
+
+@section('search')
+
+@endsection
+
+@section('content')
+
+
+
+
+
+ =$answers->appends($_GET)->links('admin.pagginate'); ?>
+
+
+@endsection
diff --git a/resources/views/admin/answers/index_ajax.blade.php b/resources/views/admin/answers/index_ajax.blade.php
new file mode 100644
index 0000000..eb56446
--- /dev/null
+++ b/resources/views/admin/answers/index_ajax.blade.php
@@ -0,0 +1,49 @@
+
+
+
+ =$answers->appends($_GET)->links('admin.pagginate'); ?>
+
diff --git a/resources/views/admin/category/index.blade.php b/resources/views/admin/category/index.blade.php
index 22ae1cc..b5fc50f 100644
--- a/resources/views/admin/category/index.blade.php
+++ b/resources/views/admin/category/index.blade.php
@@ -99,12 +99,12 @@
{{$cat->created_at}}
|
-
+ |
|
diff --git a/resources/views/admin/groups/form.blade.php b/resources/views/admin/groups/form.blade.php
index 43a4e12..4c7f621 100644
--- a/resources/views/admin/groups/form.blade.php
+++ b/resources/views/admin/groups/form.blade.php
@@ -11,7 +11,6 @@
@enderror
-
@@ -21,5 +20,38 @@
+
+
+
+
+
diff --git a/resources/views/admin/groups/index.blade.php b/resources/views/admin/groups/index.blade.php
index 99ba0a0..a824bee 100644
--- a/resources/views/admin/groups/index.blade.php
+++ b/resources/views/admin/groups/index.blade.php
@@ -102,8 +102,13 @@
{{ $group->created_at }}
|
-
- Изменить
+ |
+
|
@endforeach
diff --git a/resources/views/admin/static/index.blade.php b/resources/views/admin/static/index.blade.php
index e69de29..84a1779 100644
--- a/resources/views/admin/static/index.blade.php
+++ b/resources/views/admin/static/index.blade.php
@@ -0,0 +1,65 @@
+@extends('layout.admin', ['title' => 'Админка - Страница статистики'])
+
+@section('content')
+
+
+
+
+
+
+
+ Название |
+ Ссылка |
+
+
+
+
+
+
+
+
+ Статистика пользователей
+
+ Информация о просмотрах и сообщениях пользователей разбитая по месяцам
+
+
+
+ |
+
+ Ссылка
+ |
+
+
+
+
+
+
+ Статистика вакансий
+
+ Информация о просмотрах и отликах о вакансиях (по месяцам)
+
+
+
+ |
+
+ Ссылка
+ |
+
+
+
+
+
+
+@endsection
diff --git a/resources/views/admin/users/roles/index.blade.php b/resources/views/admin/users/roles/index.blade.php
new file mode 100644
index 0000000..764135d
--- /dev/null
+++ b/resources/views/admin/users/roles/index.blade.php
@@ -0,0 +1,238 @@
+@extends('layout.admin', ['title' => 'Роли пользователей'])
+
+@section('script')
+
+@endsection
+
+@section('search')
+
+
+@endsection
+
+@section('content')
+
+
+
+
+ //=$users->appends($_GET)->links('admin.pagginate'); ?>
+ =$users->links('admin.pagginate'); ?>
+
+
+
+
+
+
+ //=$users->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
new file mode 100644
index 0000000..3f682f8
--- /dev/null
+++ b/resources/views/admin/users/roles/index_ajax.blade.php
@@ -0,0 +1,59 @@
+
+
+
+ //=$users->appends($_GET)->links('admin.pagginate'); ?>
+ =$users->links('admin.pagginate'); ?>
+
diff --git a/routes/web.php b/routes/web.php
index a5eabf8..6ae11c2 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -149,6 +149,8 @@ Route::group([
Route::get('groups/edit/{group}', [GroupsController::class, 'edit'])->name('edit-group');
// кабинет - сохранение редактированной формы группы пользователей
Route::post('groups/edit/{group}', [GroupsController::class, 'update'])->name('update-group');
+ // кабинет - удаление группы пользователей
+ Route::delete('groups/delete/{group}', [GroupsController::class, 'destroy'])->name('delete-group');
// кабинет - список админов
Route::get('group-admin', [AdminController::class, 'index'])->name('group-admin');