From 82a9544dc9e201666cc245fce63bb786c74eddd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=20=D0=9B=D0=B0=D1=80?= =?UTF-8?q?=D0=B8=D0=BE=D0=BD=D0=BE=D0=B2?= Date: Wed, 6 Sep 2023 21:30:30 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=B2=D1=8F=D0=B7=D0=B8=20=D0=BC=D0=BE=D0=B4?= =?UTF-8?q?=D0=B5=D0=BB=D0=B5=D0=B9,=20=D0=B3=D1=80=D1=83=D0=BF=D0=BF=D1=8B=20?= =?UTF-8?q?=D0=B8=20=D1=81=D0=BE=D0=BE=D0=B1=D1=89=D0=B5=D0=BD=D0=B8=D1=8F=20?= =?UTF-8?q?=D1=81=D0=B8=D1=81=D1=82=D0=B5=D0=BC=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Admin/GroupsController.php | 72 ++++++++++++ .../Controllers/Admin/MsgAnswersController.php | 16 +++ app/Models/Ad_employer.php | 17 +++ app/Models/Employer.php | 8 ++ app/Models/Group_user.php | 22 ++++ app/Models/Job_title.php | 7 ++ app/Models/Message.php | 21 ++++ app/Models/ad_response.php | 22 ++++ composer.json | 3 +- .../2023_05_16_092746_alter_ad_jobs_table.php | 2 - .../2023_09_01_135734_create_dop_info_table.php | 2 - .../2023_09_06_090200_alter_dop_info_table.php | 46 ++++++++ .../2023_09_06_090312_alter_ad_jobs_table.php | 47 ++++++++ .../2023_09_06_100450_alter_ad_employers_table.php | 32 ++++++ resources/views/admin/ad_employers/index.blade.php | 39 +++++-- resources/views/admin/groups/add.blade.php | 11 ++ resources/views/admin/groups/edit.blade.php | 11 ++ resources/views/admin/groups/form.blade.php | 25 +++++ resources/views/admin/groups/index.blade.php | 118 ++++++++++++++++++++ resources/views/admin/index.blade.php | 26 +++++ resources/views/admin/messages.blade.php | 90 +++++++++++++++ resources/views/layout/admin.blade.php | 40 +++++++ routes/web.php | 14 ++- 23 files changed, 672 insertions(+), 19 deletions(-) create mode 100644 app/Http/Controllers/Admin/GroupsController.php create mode 100644 app/Http/Controllers/Admin/MsgAnswersController.php create mode 100644 database/migrations/2023_09_06_090200_alter_dop_info_table.php create mode 100644 database/migrations/2023_09_06_090312_alter_ad_jobs_table.php create mode 100644 database/migrations/2023_09_06_100450_alter_ad_employers_table.php create mode 100644 resources/views/admin/groups/add.blade.php create mode 100644 resources/views/admin/groups/edit.blade.php create mode 100644 resources/views/admin/groups/form.blade.php create mode 100644 resources/views/admin/groups/index.blade.php create mode 100644 resources/views/admin/messages.blade.php diff --git a/app/Http/Controllers/Admin/GroupsController.php b/app/Http/Controllers/Admin/GroupsController.php new file mode 100644 index 0000000..22f1a5f --- /dev/null +++ b/app/Http/Controllers/Admin/GroupsController.php @@ -0,0 +1,72 @@ +paginate(15); + return view('admin.groups.index', compact('groups')); + } + + // форма добавления группы + public function add() { + $editor = Auth::user()->id; + return view('admin.groups.add', compact('editor')); + } + + // форма сохранения добавленной группы + public function store(Request $request) { + $rules = [ + 'name_group' => 'required|min:3', + ]; + $messages = [ + 'required' => 'Укажите обязательное поле', + ]; + $validator = Validator::make($request->all(), $rules, $messages); + + if ($validator->fails()) { + return redirect()->route('admin.add-group') + ->withErrors($validator); + } else { + Group_user::create($request->all()); + return redirect()->route('admin.groups') + ->with('success', 'Данные были успешно сохранены'); + } + return redirect()->route('admin.groups'); + } + + // форма редактирования группы + public function edit(Group_user $group, Request $request) { + $editor = Auth::user()->id; + return view('admin.groups.edit', compact('editor', 'group')); + } + + // форма сохранения редактированной группы + public function update(Group_user $group, Request $request) { + $rules = [ + 'name_group' => 'required|min:3', + ]; + $messages = [ + 'required' => 'Укажите обязательное поле', + ]; + $validator = Validator::make($request->all(), $rules, $messages); + + if ($validator->fails()) { + return redirect()->route('admin.edit-group', ['group' => $group->id]) + ->withErrors($validator); + } else { + $group->update($request->all()); + return redirect()->route('admin.groups') + ->with('success', 'Данные были успешно сохранены'); + } + return redirect()->route('admin.groups'); + } +} diff --git a/app/Http/Controllers/Admin/MsgAnswersController.php b/app/Http/Controllers/Admin/MsgAnswersController.php new file mode 100644 index 0000000..89dedef --- /dev/null +++ b/app/Http/Controllers/Admin/MsgAnswersController.php @@ -0,0 +1,16 @@ +orderByDesc('created_at')->paginate(25); + + return view('admin.messages', compact('Msgs')); + } +} diff --git a/app/Models/Ad_employer.php b/app/Models/Ad_employer.php index 8a0025a..ca17d8b 100644 --- a/app/Models/Ad_employer.php +++ b/app/Models/Ad_employer.php @@ -11,8 +11,25 @@ class Ad_employer extends Model /* * Связь таблицы employers с таблицей ad_employers + многие-к-одному */ public function employer() { return $this->belongsTo(Employer::class, 'employer_id'); } + + /* + * Связь модели Вакансии (Ad_employer) с моделью Должности (Job_title) + многие-ко-многим + */ + public function jobs() { + return $this->belongsToMany(Job_title::class, 'ad_jobs'); + } + + /* + * Связь модели Вакансия (Ad_employers) с моделью Отклик на Вакансию (Ad_response) + один-ко-многим + */ + public function response() { + return $this->hasMany(ad_response::class); + } } diff --git a/app/Models/Employer.php b/app/Models/Employer.php index f3d74d9..aae29aa 100644 --- a/app/Models/Employer.php +++ b/app/Models/Employer.php @@ -30,4 +30,12 @@ class Employer extends Model return $this->belongsTo(User::class, 'user_id'); } + /* + * Связь Работодателя с вакансиями + */ + public function ads() { + return $this->hasMany(Ad_employer::class); + } + + } diff --git a/app/Models/Group_user.php b/app/Models/Group_user.php index 46f384b..50bf2c4 100644 --- a/app/Models/Group_user.php +++ b/app/Models/Group_user.php @@ -8,4 +8,26 @@ use Illuminate\Database\Eloquent\Model; class Group_user extends Model { use HasFactory; + + protected $fillable = [ + 'name_group', + 'user_id', + ]; + + /* + * Связь Модели Группы (Group_user) с Модели Юзеры (User) + многие-к-одному + */ + public function user() { + return $this->belongsTo(User::class, 'user_id'); + } + + /* + * Связь модели Группы (Group_user) с Моделью Юзеры (User) - участники группы + многие-ко-многим + */ + public function ingroup() { + return $this->belongsToMany(User::class, 'group_works'); + } + } diff --git a/app/Models/Job_title.php b/app/Models/Job_title.php index 12074da..a21dc75 100644 --- a/app/Models/Job_title.php +++ b/app/Models/Job_title.php @@ -8,4 +8,11 @@ use Illuminate\Database\Eloquent\Model; class Job_title extends Model { use HasFactory; + + /* + * Связь модели Вакансии (Ad_employer) с моделью Должности (Job_title) + */ + public function Ads() { + return $this->belongsToMany(Ad_employer::class, 'ad_jobs'); + } } diff --git a/app/Models/Message.php b/app/Models/Message.php index b9f7393..fcb867d 100644 --- a/app/Models/Message.php +++ b/app/Models/Message.php @@ -8,4 +8,25 @@ use Illuminate\Database\Eloquent\Model; class Message extends Model { use HasFactory; + + /* + * Связь таблицы Message с таблицей User (Отправитель) + */ + public function user_from() { + return $this->belongsTo(User::class, 'user_id'); + } + + /* + * Связь таблицы Message с таблицей User (Получатель) + */ + public function user_to() { + return $this->belongsTo(User::class, 'to_user_id'); + } + + /* + * Связь модели Сообщения (Message) с моделью Отклик на Вакансию (Ad_response) + */ + public function response() { + return $this->hasMany(ad_response::class); + } } diff --git a/app/Models/ad_response.php b/app/Models/ad_response.php index 7b014e2..22bb18e 100644 --- a/app/Models/ad_response.php +++ b/app/Models/ad_response.php @@ -8,4 +8,26 @@ use Illuminate\Database\Eloquent\Model; class ad_response extends Model { use HasFactory; + + /* + * Связь таблицы Отклик на вакансию (ad_response) с таблицей Вакансия (ad_employer) + */ + public function ad_employer() { + return $this->belongsTo(Ad_employer::class, 'ad_employer_id'); + } + + /* + * Связь таблицы Отклик на вакансию (ad_response) с таблицей Должность (job_title) + */ + public function job_title() { + return $this->belongsTo(Job_title::class, 'job_title_id'); + } + + /* + * Связь таблицы Отклик на вакансию (ad_response) с таблицей Сообщение (messages) + */ + public function message() { + return $this->belongsTo(Message::class, 'message_id'); + } + } diff --git a/composer.json b/composer.json index fbf6301..5593579 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,8 @@ "laravel/framework": "^9.19", "laravel/sanctum": "^3.0", "laravel/tinker": "^2.7", - "laravel/ui": "^4.2" + "laravel/ui": "^4.2", + "ext-http": "*" }, "require-dev": { "fakerphp/faker": "^1.9.1", diff --git a/database/migrations/2023_05_16_092746_alter_ad_jobs_table.php b/database/migrations/2023_05_16_092746_alter_ad_jobs_table.php index 11167d5..83389dd 100644 --- a/database/migrations/2023_05_16_092746_alter_ad_jobs_table.php +++ b/database/migrations/2023_05_16_092746_alter_ad_jobs_table.php @@ -15,8 +15,6 @@ return new class extends Migration { Schema::create('ad_jobs', function (Blueprint $table) { $table->id(); - $table->bigInteger('ad_employer_id')->nullable(false); - $table->bigInteger('job_title_id')->nullable(false); $table->timestamps(); }); } diff --git a/database/migrations/2023_09_01_135734_create_dop_info_table.php b/database/migrations/2023_09_01_135734_create_dop_info_table.php index 5e7ebf9..ebfe875 100644 --- a/database/migrations/2023_09_01_135734_create_dop_info_table.php +++ b/database/migrations/2023_09_01_135734_create_dop_info_table.php @@ -15,8 +15,6 @@ return new class extends Migration { Schema::create('dop_info', function (Blueprint $table) { $table->id(); - $table->bigInteger('worker_id')->nullable(false); - $table->bigInteger('infoblok_id')->nullable(false); $table->text('text')->nullable(); $table->timestamps(); }); diff --git a/database/migrations/2023_09_06_090200_alter_dop_info_table.php b/database/migrations/2023_09_06_090200_alter_dop_info_table.php new file mode 100644 index 0000000..b2d366b --- /dev/null +++ b/database/migrations/2023_09_06_090200_alter_dop_info_table.php @@ -0,0 +1,46 @@ +unsignedBigInteger('infoblok_id')->nullable(); + //внешний ключ, ссылается на поле id таблицы infobloks + $table->foreign('infoblok_id', 'key_infoblok_id') + ->references('id') + ->on('infobloks') + ->onDelete('cascade'); + + $table->unsignedBigInteger('worker_id')->nullable(); + //внешний ключ, ссылается на поле id таблицы workers + $table->foreign('worker_id', 'key_worker_id') + ->references('id') + ->on('workers') + ->onDelete('cascade'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('dop_info', function (Blueprint $table) { + $table->dropIndex(['key_infoblok_id']); + $table->dropIndex(['key_worker_id']); + }); + } +}; diff --git a/database/migrations/2023_09_06_090312_alter_ad_jobs_table.php b/database/migrations/2023_09_06_090312_alter_ad_jobs_table.php new file mode 100644 index 0000000..ef15a98 --- /dev/null +++ b/database/migrations/2023_09_06_090312_alter_ad_jobs_table.php @@ -0,0 +1,47 @@ +unsignedBigInteger('ad_employer_id')->nullable(); + //внешний ключ, ссылается на поле id таблицы ad_employers + $table->foreign('ad_employer_id', 'key_ad_employer_id') + ->references('id') + ->on('ad_employers') + ->onDelete('cascade'); + + $table->unsignedBigInteger('job_title_id')->nullable(); + //внешний ключ, ссылается на поле id таблицы job_titles + $table->foreign('job_title_id', 'key_job_title_id') + ->references('id') + ->on('job_titles') + ->onDelete('cascade'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('ad_jobs', function (Blueprint $table) { + $table->dropIndex(['key_ad_employer_id']); + $table->dropIndex(['key_job_title_id']); + $table->dropColumn('job_title_id'); + $table->dropColumn('ad_employer_id'); + }); + } +}; diff --git a/database/migrations/2023_09_06_100450_alter_ad_employers_table.php b/database/migrations/2023_09_06_100450_alter_ad_employers_table.php new file mode 100644 index 0000000..cc15d8d --- /dev/null +++ b/database/migrations/2023_09_06_100450_alter_ad_employers_table.php @@ -0,0 +1,32 @@ +string('name', 255)->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('ad_employers', function (Blueprint $table) { + $table->dropColumn('name'); + }); + } +}; diff --git a/resources/views/admin/ad_employers/index.blade.php b/resources/views/admin/ad_employers/index.blade.php index fe7b5d0..fd8d1fe 100644 --- a/resources/views/admin/ad_employers/index.blade.php +++ b/resources/views/admin/ad_employers/index.blade.php @@ -1,10 +1,10 @@ -@extends('layout.admin', ['title' => 'Админка - Работодатели']) +@extends('layout.admin', ['title' => 'Админка - Вакансии']) @section('script') @endsection @section('search') -
+ @endsection @section('content') @@ -41,9 +41,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" > № + Название объявления Название компании Вакансии Город + З/п Дата @@ -54,17 +56,27 @@ {{$ad->id}} - {{$ad->employers->name_company}} + {{$ad->name}} + + + {{$ad->employer->name_company}}
+ @if ($ad->jobs->count())
- -

-

-

- + + @foreach ($ad->jobs as $title) + +

{{$title->name}}

+ +

/ {{$title->name}}

+ + @endforeach
+ @endif
@@ -72,6 +84,9 @@ {{ $ad->city }} + {{ $ad->salary }} + + {{ $ad->created_at }} @@ -81,7 +96,7 @@
- appends($_GET)->links('admin.pagginate'); ?> + appends($_GET)->links('admin.pagginate'); ?>
@endsection diff --git a/resources/views/admin/groups/add.blade.php b/resources/views/admin/groups/add.blade.php new file mode 100644 index 0000000..5ec26f5 --- /dev/null +++ b/resources/views/admin/groups/add.blade.php @@ -0,0 +1,11 @@ +@extends('layout.admin', ['title' => 'Админка - Добавление новой группы']) + +@section('content') +

+ Добавление новой группы +

+
+ @csrf + @include('admin.groups.form') +
+@endsection diff --git a/resources/views/admin/groups/edit.blade.php b/resources/views/admin/groups/edit.blade.php new file mode 100644 index 0000000..e3e1324 --- /dev/null +++ b/resources/views/admin/groups/edit.blade.php @@ -0,0 +1,11 @@ +@extends('layout.admin', ['title' => 'Админка - Редактирование группы']) + +@section('content') +

+ Редактирование группы +

+
+ @csrf + @include('admin.groups.form') +
+@endsection diff --git a/resources/views/admin/groups/form.blade.php b/resources/views/admin/groups/form.blade.php new file mode 100644 index 0000000..43a4e12 --- /dev/null +++ b/resources/views/admin/groups/form.blade.php @@ -0,0 +1,25 @@ +
+
+ + + +
+
+ +
+
+
+ diff --git a/resources/views/admin/groups/index.blade.php b/resources/views/admin/groups/index.blade.php new file mode 100644 index 0000000..99ba0a0 --- /dev/null +++ b/resources/views/admin/groups/index.blade.php @@ -0,0 +1,118 @@ +@extends('layout.admin', ['title' => 'Админка - Группы пользователей']) + +@section('script') + +@endsection + +@section('search') + +@endsection + +@section('content') +
+
+ Создать группу

+ + + + + + + + + + + + + @foreach($groups as $group) + + + + + + + + + @endforeach + +
Название группыСоздатель группыКол-во участниковДата регистрацииИзменить
+ {{$group->id}} + + {{$group->name_group}} + + {{$group->user->name}} + + {{$group->ingroup->count()}} + + {{ $group->created_at }} + + Изменить +
+
+ +
+ appends($_GET)->links('admin.pagginate'); ?> +
+
+@endsection diff --git a/resources/views/admin/index.blade.php b/resources/views/admin/index.blade.php index 646087c..8c38780 100644 --- a/resources/views/admin/index.blade.php +++ b/resources/views/admin/index.blade.php @@ -422,6 +422,32 @@ сентябрь 2023 + + +
+ +
+

Модерация

+

+ Модерация отзывов о работодателе +

+
+
+ + + answers + + + + Доступно + + + + сентябрь 2023 + + +@endsection + +@section('content') +
+
+ + + + + + + + + + + + + @foreach($Msgs as $msg) + + + + + + + + + @endforeach + +
От юзераК юзеруЗаголовокОткликДата
+ {{$msg->id}} + + {{$msg->user_from->name}} ({{$msg->user_from->id}}) + + {{$msg->user_to->name}} ({{$msg->user_to->id}}) + + {{$msg->title}} + +
+
+ @if ($msg->response->count()) + Да + @else + Нет + @endif +
+
+
+ {{ $msg->created_at }} +
+
+ +
+ appends($_GET)->links('admin.pagginate'); ?> +
+
+@endsection diff --git a/resources/views/layout/admin.blade.php b/resources/views/layout/admin.blade.php index f89aa03..48f17b9 100644 --- a/resources/views/layout/admin.blade.php +++ b/resources/views/layout/admin.blade.php @@ -235,6 +235,26 @@ Статистика +
  • + + + Модерация + +
  • +
  • + + + Сообщения + +