From a67c9d7ef4a8e42af8fdcd3778dffb18791677a0 Mon Sep 17 00:00:00 2001 From: Sergey Panarin Date: Tue, 6 Aug 2024 18:27:07 +0200 Subject: [PATCH] =?UTF-8?q?=D0=9C=D0=B0=D1=81=D1=81=D0=BE=D0=B2=D0=B0=D1=8F=20?= =?UTF-8?q?=D1=80=D0=B0=D1=81=D1=81=D1=8B=D0=BB=D0=BA=D0=B0=20=D1=81=D0=BE=D0?= =?UTF-8?q?=BE=D0=B1=D1=89=D0=B5=D0=BD=D0=B8=D0=B9=20+=20=D0=BF=D1=80=D0=B0=D0?= =?UTF-8?q?=B2=D0=BA=D0=B8=20=D0=BE=D1=82=20=D0=9C=D0=B0=D1=80=D0=B8=D0=BD=D1?= =?UTF-8?q?=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/EmployerController.php | 29 ++++++-- app/Mail/MassSendingMessages.php | 44 +++++++++++++ app/Models/MessagesRequests.php | 19 ++++++ ..._08_05_094303_create_message_requests_table.php | 36 ++++++++++ .../emails/added_mass_sending_messages.blade.php | 3 + resources/views/employers/send_all.blade.php | 65 ++++-------------- resources/views/info_company_new.blade.php | 8 +-- resources/views/js/favorite-worker.blade.php | 69 ++++++++------------ resources/views/resume.blade.php | 14 ---- resources/views/resume/resume_blocks.blade.php | 2 +- resources/views/worker.blade.php | 4 +- 11 files changed, 171 insertions(+), 122 deletions(-) create mode 100644 app/Mail/MassSendingMessages.php create mode 100644 app/Models/MessagesRequests.php create mode 100644 database/migrations/2024_08_05_094303_create_message_requests_table.php create mode 100644 resources/views/emails/added_mass_sending_messages.blade.php diff --git a/app/Http/Controllers/EmployerController.php b/app/Http/Controllers/EmployerController.php index aa255a3..d3020ff 100644 --- a/app/Http/Controllers/EmployerController.php +++ b/app/Http/Controllers/EmployerController.php @@ -10,6 +10,7 @@ use App\Http\Requests\MessagesRequiest; use App\Http\Requests\VacancyRequestEdit; use App\Mail\MailCreateEmployer; use App\Mail\MailSotrudnichestvo; +use App\Mail\MassSendingMessages; use App\Mail\SendAllMessages; use App\Models\Ad_employer; use App\Models\ad_response; @@ -21,6 +22,7 @@ use App\Models\Job_title; use App\Models\Like_worker; use App\Models\Message; use App\Models\Worker; +use App\Models\MessagesRequests; use Carbon\Carbon; use Illuminate\Auth\Events\Registered; use Illuminate\Database\Eloquent\Builder; @@ -736,8 +738,16 @@ class EmployerController extends Controller public function send_all_messages() { $id = Auth()->user()->id; $sending = Employer::query()->where('user_id', '=', "$id")->first(); + + $job_titles = Job_title::query() + ->where('is_remove', '=', 0) + ->where('is_bd', '=', 1) + ->orderByDesc('sort') + ->get() + ; + if ($sending->sending_is) - return view('employers.send_all'); + return view('employers.send_all', compact('job_titles')); else return view('employers.send_all_danger'); } @@ -745,14 +755,25 @@ class EmployerController extends Controller // Отправка сообщений для информации public function send_all_post(Request $request) { $data = $request->all(); + $data['user'] = Auth()->user(); - $emails = User_Model::query()->where('is_worker', '1')->get(); + $id = MessagesRequests::create([ + 'user_id' => Auth()->user()->id, + 'job_titles' => json_encode($data['job_title_ids']), + 'text' => $data['message_text'], + ]); + + if (!empty($id)){ + Mail::to(env('EMAIL_ADMIN'))->send(new MassSendingMessages($data)); + } + + /*$emails = User_Model::query()->where('is_worker', '1')->get(); foreach ($emails as $e) { Mail::to($e->email)->send(new SendAllMessages($data)); - } + }*/ - return redirect()->route('employer.send_all_messages')->with('success', 'Письма были отправлены'); + return redirect()->route('employer.send_all_messages')->with('success', 'Запрос на рассылку был успешно отправлен.'); } // База резюме diff --git a/app/Mail/MassSendingMessages.php b/app/Mail/MassSendingMessages.php new file mode 100644 index 0000000..4eb5f73 --- /dev/null +++ b/app/Mail/MassSendingMessages.php @@ -0,0 +1,44 @@ +data = $data; + } + + public function envelope(): Envelope + { + return new Envelope( + subject: 'Запрос на рассылку сообщений', + ); + } + + public function build() + { + + // Вернуть все данные + return $this->view('emails.added_mass_sending_messages', ['data' => $this->data]); + } + + + public function attachments(): array + { + return []; + } +} diff --git a/app/Models/MessagesRequests.php b/app/Models/MessagesRequests.php new file mode 100644 index 0000000..83d334f --- /dev/null +++ b/app/Models/MessagesRequests.php @@ -0,0 +1,19 @@ +id(); + $table->bigInteger('user_id')->nullable(false); + $table->text('job_titles')->nullable(false); + $table->text('text')->nullable(); + $table->dateTime('is_rejected')->nullable(true); + $table->dateTime('is_sent')->nullable(true); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('messages_requests'); + } +}; diff --git a/resources/views/emails/added_mass_sending_messages.blade.php b/resources/views/emails/added_mass_sending_messages.blade.php new file mode 100644 index 0000000..61191a5 --- /dev/null +++ b/resources/views/emails/added_mass_sending_messages.blade.php @@ -0,0 +1,3 @@ +
+ Добавлен новый запрос на рассылку от "{{ $data['user']->name }}". +
diff --git a/resources/views/employers/send_all.blade.php b/resources/views/employers/send_all.blade.php index f1d7054..9179982 100644 --- a/resources/views/employers/send_all.blade.php +++ b/resources/views/employers/send_all.blade.php @@ -26,70 +26,27 @@

Рассылка сообщений

@include('messages_error') -

Контактные данные

-

Все поля обязательны для заполнения *

-
-
-
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
-
-

Ваше сообщение

-
- +
- +
+ +
- +
diff --git a/resources/views/info_company_new.blade.php b/resources/views/info_company_new.blade.php index 9e8c44a..24094d0 100644 --- a/resources/views/info_company_new.blade.php +++ b/resources/views/info_company_new.blade.php @@ -211,10 +211,10 @@ @endif -
{{ $flot->name }}
-
DWT
{{ $flot->DWT }}
-
Мощность
{{ $flot->POWER_GD }}
-
IMO
{{ $flot->IMO }}
+
Название:
{{ $flot->name }}
+
DWT:
{{ $flot->DWT }}
+
Мощность:
{{ $flot->POWER_GD }}
+
IMO:
{{ $flot->IMO }}
@endforeach @endif diff --git a/resources/views/js/favorite-worker.blade.php b/resources/views/js/favorite-worker.blade.php index 8d3c42a..0a7b825 100644 --- a/resources/views/js/favorite-worker.blade.php +++ b/resources/views/js/favorite-worker.blade.php @@ -1,52 +1,35 @@ diff --git a/resources/views/resume.blade.php b/resources/views/resume.blade.php index aae36bb..184bddc 100644 --- a/resources/views/resume.blade.php +++ b/resources/views/resume.blade.php @@ -32,21 +32,7 @@