From 09a2fc9d81f0ca1b30ea802e4feba1517179fc45 Mon Sep 17 00:00:00 2001 From: anazaryan Date: Tue, 10 Dec 2024 17:37:38 +0400 Subject: [PATCH] messages and subscribe email --- app/Console/Commands/CreateAdminChat.php | 64 +++++++++++++ app/Console/Commands/RemoveOldUsers.php | 105 ++++++++++++++++++++++ app/Http/Controllers/EmployerController.php | 24 +++-- app/Http/Controllers/WorkerController.php | 33 ++++++- app/Mail/SendMessage.php | 72 +++++++++++++++ app/Mail/SendVacancyMessage.php | 75 ++++++++++++++++ app/Models/Chat.php | 17 ++-- app/Models/Message.php | 21 +++-- app/Models/User.php | 8 ++ app/Observers/MessageObserver.php | 88 ++++++++++++++++++ app/Observers/UserObserver.php | 74 +++++++++++++++ app/Providers/AppServiceProvider.php | 9 ++ config/admin.php | 4 + resources/views/chats/chats_list.blade.php | 10 ++- resources/views/emails/message.blade.php | 63 +++++++++++++ resources/views/emails/message_vacancy.blade.php | 63 +++++++++++++ resources/views/employers/dialog.blade.php | 101 +++++++++++++-------- resources/views/employers/subcribe.blade.php | 9 +- resources/views/list_vacancies.blade.php | 4 +- resources/views/workers/dialog.blade.php | 39 +++++--- resources/views/workers/menu.blade.php | 7 ++ resources/views/workers/subcribe.blade.php | 51 +++++++++++ routes/web.php | 6 +- 23 files changed, 854 insertions(+), 93 deletions(-) create mode 100644 app/Console/Commands/CreateAdminChat.php create mode 100644 app/Console/Commands/RemoveOldUsers.php create mode 100644 app/Mail/SendMessage.php create mode 100644 app/Mail/SendVacancyMessage.php create mode 100644 app/Observers/MessageObserver.php create mode 100644 app/Observers/UserObserver.php create mode 100644 config/admin.php create mode 100644 resources/views/emails/message.blade.php create mode 100644 resources/views/emails/message_vacancy.blade.php create mode 100644 resources/views/workers/subcribe.blade.php diff --git a/app/Console/Commands/CreateAdminChat.php b/app/Console/Commands/CreateAdminChat.php new file mode 100644 index 0000000..18a116c --- /dev/null +++ b/app/Console/Commands/CreateAdminChat.php @@ -0,0 +1,64 @@ +id)->get(); + $chats = Chat::where('is_admin_chat', 1) + ->get(); + + foreach ($chats as $chat) { + $chat->delete(); + } + + $loopCount = $users->count(); + + if ($superAdmin){ + foreach ($users as $user){ + Chat::firstOrCreate([ + 'user_id' => $user->id, + 'to_user_id' => $superAdmin->id, + 'is_admin_chat' => 1, + 'is_removed' => 0, + ]); + + } + + $this->info("Admin chats created for {$loopCount} users." ); + + return Command::SUCCESS; + } + + $this->error("Admin is missing!" ); + + } + +} diff --git a/app/Console/Commands/RemoveOldUsers.php b/app/Console/Commands/RemoveOldUsers.php new file mode 100644 index 0000000..d27913b --- /dev/null +++ b/app/Console/Commands/RemoveOldUsers.php @@ -0,0 +1,105 @@ +where('created_at', '<', $date) + ->pluck('id'); + + if ($users->isEmpty()) { + $this->info('No users to delete.'); + return 0; + } + + $this->info('Found ' . $users->count() . ' users to delete.'); + + $userRelatedTables = [ + 'answers', + 'chats', + 'employers', + 'group_users', + 'group_works', +// 'like_vacancy', +// 'like_worker', + 'media', + 'messages', + 'messages_requests', + 'static_workers', + 'workers', + ]; + + $workerEmployerRelatedTables = [ + 'ad_employers' => 'employer_id', + 'answers' => 'employer_id', + 'employers_mains' => 'employer_id', + 'employer_autolift_options' => 'employer_id', + 'flots' => 'employer_id', + 'place_works' => 'worker_id', + 'prev_company' => 'worker_id', + 'response_works' => 'worker_id', + 'sertifications' => 'worker_id', + 'title_workers' => 'worker_id', + 'worker_autolift_options' => 'worker_id', + ]; + + try { + DB::beginTransaction(); + + foreach ($userRelatedTables as $table) { + DB::table($table)->whereIn('user_id', $users)->delete(); + $this->info("Removed related records from table: $table"); + } + + $workerIds = DB::table('workers')->whereIn('user_id', $users)->pluck('id'); + $employerIds = DB::table('employers')->whereIn('user_id', $users)->pluck('id'); + + foreach ($workerEmployerRelatedTables as $table => $column) { + DB::table($table)->whereIn($column, str_contains($column, 'worker') ? $workerIds : $employerIds)->delete(); + $this->info("Removed related records for table: $table"); + } + foreach (['like_vacancy', 'like_worker'] as $table) { + DB::table($table)->whereIn('user_id', $users->map(fn($id) => (string)$id))->delete(); + DB::table($table)->whereIn('user_id', $users->map(fn($id) => (string)$id))->delete(); + $this->info("Removed related records from table: $table (VARCHAR user_id)"); + } + DB::table('workers')->whereIn('id', $workerIds)->delete(); + DB::table('employers')->whereIn('id', $employerIds)->delete(); + DB::table('users')->whereIn('id', $users)->delete(); + + DB::commit(); + $this->info('All related data and users have been removed successfully.'); + } catch (\Exception $e) { + DB::rollBack(); + $this->error('An error occurred: ' . $e->getMessage()); + } + + return 0; + } + +} diff --git a/app/Http/Controllers/EmployerController.php b/app/Http/Controllers/EmployerController.php index c8ecb0b..c8f18f8 100644 --- a/app/Http/Controllers/EmployerController.php +++ b/app/Http/Controllers/EmployerController.php @@ -350,12 +350,12 @@ class EmployerController extends Controller //Страницы сообщений список public function messages($type_message) { $user_id = Auth()->user()->id; - + $superAdmin =User_Model::superAdmin(); $chats = Chat::get_user_chats($user_id); + $admin_chat = Chat::get_user_admin_chat($user_id); $user_type = 'employer'; - $admin_chat = false; - return view('employers.messages', compact('chats', 'admin_chat', 'user_id', 'user_type')); + return view('employers.messages', compact('chats', 'admin_chat', 'user_id', 'user_type','superAdmin')); } // Диалог между пользователями @@ -366,6 +366,7 @@ class EmployerController extends Controller } else { $ad_employer = 0; } + $superAdmin =User_Model::superAdmin(); $sender = User_Model::query()->with('workers')->with('employers')->where('id', $chat->user_id)->first(); $companion = User_Model::query()->with('workers')->with('employers')->where('id', $chat->to_user_id)->first(); @@ -374,7 +375,7 @@ class EmployerController extends Controller Message::where('user_id', '=', $chat->to_user_id)->where('to_user_id', '=', $chat->user_id)->update(['flag_new' => 0]); - return view('employers.dialog', compact('companion', 'sender', 'ad_employer', 'Messages')); + return view('employers.dialog', compact('companion', 'sender', 'ad_employer', 'Messages','chat','superAdmin')); } public function pin_chat(Request $request){ @@ -610,13 +611,20 @@ class EmployerController extends Controller //Установка уведомлений сохранение public function save_subscribe(Request $request) { -// dd($request->all()); + $msg = $request->validate([ - 'subscribe_email' => 'required|email|min:5|max:255', - ]); + 'email' => 'required|email|min:5|max:255', + ]); + $user= Auth::user(); + + User_Model::updateOrCreate( + ['id' => $user->id], + ['subscribe_email' => $request->email, + 'subscribe' => request()->has('email_msg') && request('email_msg') === 'on' ? 1 : 0 + ] + ); return redirect()->route('employer.subscribe')->with('Вы успешно подписались на рассылку'); } - //Сбросить форму с паролем public function password_reset() { $email = Auth()->user()->email; diff --git a/app/Http/Controllers/WorkerController.php b/app/Http/Controllers/WorkerController.php index 4507a42..c0aa0cb 100644 --- a/app/Http/Controllers/WorkerController.php +++ b/app/Http/Controllers/WorkerController.php @@ -772,7 +772,11 @@ class WorkerController extends Controller 'Job_title')); } - + public function pin_chat(Request $request){ + $chat_id = $request->get('id'); + $is_fixed = $request->get('is_fixed'); + Chat::pin_chat($chat_id, $is_fixed); + } //Переписка public function dialog(Chat $chat, Request $request) { // Получение параметров. @@ -781,7 +785,7 @@ class WorkerController extends Controller } else { $ad_employer = 0; } - + $supeAdmin=User::superAdmin(); $sender = User_Model::query()->with('workers')->with('employers')->where('id', $chat->user_id)->first(); $companion = User_Model::query()->with('workers')->with('employers')->where('id', $chat->to_user_id)->first(); @@ -789,7 +793,7 @@ class WorkerController extends Controller Message::where('chat_id_to', '=', $chat->id)->update(['flag_new' => 0]); - return view('workers.dialog', compact('companion', 'sender', 'chat', 'Messages', 'ad_employer')); + return view('workers.dialog', compact('companion', 'sender', 'chat', 'Messages', 'ad_employer','supeAdmin')); } // Даунылоады @@ -889,7 +893,30 @@ class WorkerController extends Controller return redirect()->route('worker.additional_documents')->with('success', 'Успешно сохранено!'); } + public function subscribe() { + + $user= Auth::user(); + return view('workers.subcribe',compact('user')); + } + + //Установка уведомлений сохранение + public function save_subscribe(Request $request) { + $msg = $request->validate([ + 'email' => 'required|email|min:5|max:255', + ]); + + $user= Auth::user(); + + User_Model::updateOrCreate( + ['id' => $user->id], + ['subscribe_email' => $request->email, + 'subscribe' => request()->has('email_msg') && request('email_msg') === 'on' ? 1 : 0 + ] + ); + return redirect()->route('worker.subscribe')->with('Вы успешно подписались на рассылку'); + + } public function delete_add_diplom(Request $request, Worker $worker) { $infoblok_id = $request->get('infoblok_id'); diff --git a/app/Mail/SendMessage.php b/app/Mail/SendMessage.php new file mode 100644 index 0000000..37f4bb1 --- /dev/null +++ b/app/Mail/SendMessage.php @@ -0,0 +1,72 @@ +messageText = $message->text; + $this->userName = $user->name; + $this->link = route('employer.dialog', ['chat' => $message->chat_id_from]); + + } + + /** + * Get the message envelope. + * + * @return \Illuminate\Mail\Mailables\Envelope + */ + public function envelope() + { + return new Envelope( + subject: 'У вас новое личное сообщение!', + ); + } + + /** + * Get the message content definition. + * + * @return \Illuminate\Mail\Mailables\Content + */ + public function content() + { + + return new Content( + view: 'emails.message', + with: [ + 'text' => $this->messageText, + 'userName' => $this->userName, + 'link' => $this->link, + ], + ); + } + + /** + * Get the attachments for the message. + * + * @return array + */ + public function attachments() + { + return []; + } +} diff --git a/app/Mail/SendVacancyMessage.php b/app/Mail/SendVacancyMessage.php new file mode 100644 index 0000000..0fe2788 --- /dev/null +++ b/app/Mail/SendVacancyMessage.php @@ -0,0 +1,75 @@ +messageText = $message->text; + $this->userName = $user->name; + $this->vacancy = $vacancy->name; + $this->link = route('employer.dialog', ['chat' => $message->chat_id_from]); + + } + + /** + * Get the message envelope. + * + * @return \Illuminate\Mail\Mailables\Envelope + */ + public function envelope() + { + return new Envelope( + subject: 'Отклик на вашу вакансию!', + ); + } + + /** + * Get the message content definition. + * + * @return \Illuminate\Mail\Mailables\Content + */ + public function content() + { + + return new Content( + view: 'emails.message_vacancy', + with: [ + 'text' => $this->messageText, + 'userName' => $this->userName, + 'link' => $this->link, + 'vacancy' => $this->vacancy, + ], + ); + } + + /** + * Get the attachments for the message. + * + * @return array + */ + public function attachments() + { + return []; + } +} diff --git a/app/Models/Chat.php b/app/Models/Chat.php index 51b843b..e6199ce 100644 --- a/app/Models/Chat.php +++ b/app/Models/Chat.php @@ -49,6 +49,7 @@ class Chat extends Model public static function pin_chat(int $chat_id, $fixed) { + return self::where('id', '=', $chat_id) ->update([ 'is_fixed' => !empty($fixed) ? 1 : 0, @@ -88,24 +89,17 @@ class Chat extends Model { return Chat::query() ->with('last_message') - ->withCount(['admin_chat_unread_messages' => function ($query) use($user_id) { - $query->whereNull('chat_id_from')->where('to_user_id', '=', $user_id)->where('flag_new', '=', 1); + ->withCount(['unread_messages' => function ($query) use($user_id) { + $query->where('to_user_id', '=', $user_id)->where('flag_new', '=', 1); }]) - ->where('to_user_id', '=', $user_id) + ->where('user_id', '=', $user_id) ->where('is_admin_chat', 1) ->first() ; } public static function get_chat_messages(Chat $chat){ - if ($chat->is_admin_chat){ - return Message::query() - ->where('chat_id_to', $chat->id) - ->where('to_user_id', $chat->to_user_id) - ->orderBy('created_at') - ->get() - ; - } else { + return Message::query() ->where(function ($query) use ($chat) { $query->where('chat_id_from', $chat->id)->orWhere('chat_id_to', $chat->id); @@ -123,7 +117,6 @@ class Chat extends Model ->OrderBy('created_at') ->get() ; - } } } diff --git a/app/Models/Message.php b/app/Models/Message.php index bd03349..b548388 100644 --- a/app/Models/Message.php +++ b/app/Models/Message.php @@ -56,6 +56,14 @@ class Message extends Model string $file_store_path = '/', bool $is_admin_chat = false ) { + + $superAdmin =User::superAdmin(); + + if ($superAdmin && $superAdmin->id == $to_user_id ){ + + $is_admin_chat=true; + } + $message_params['user_id'] = $user_id; $message_params['to_user_id'] = $to_user_id; $files = $request->file(); @@ -66,21 +74,20 @@ class Message extends Model } $chat_form = Chat::firstOrCreate([ - 'user_id' => $is_admin_chat ? 0 : $user_id, + 'user_id' => $user_id, 'to_user_id' => $to_user_id, 'is_removed' => 0, 'is_admin_chat' => $is_admin_chat ? 1 : 0, ]); - $message_params[$is_admin_chat ? 'chat_id_to' : 'chat_id_from'] = $chat_form->id; + $message_params['chat_id_from'] = $chat_form->id; + - if (!$is_admin_chat) { $chat_to = Chat::firstOrCreate([ 'user_id' => $to_user_id, 'to_user_id' => $user_id, - 'is_removed' => 0 + 'is_removed' => 0, ]); $message_params['chat_id_to'] = $chat_to->id; - } //dump('before creation '.$message_params['text']); $new_message = Message::create($message_params); @@ -89,9 +96,7 @@ class Message extends Model if ($new_message->id > $chat_form->last_message_id) { $chat_form->update(['last_message_date' => date("Y-m-d H:i:s"), 'last_message_id' => $new_message->id]); - if (!$is_admin_chat) { - $chat_to->update(['last_message_date' => date("Y-m-d H:i:s"), 'last_message_id' => $new_message->id]); - } + $chat_to->update(['last_message_date' => date("Y-m-d H:i:s"), 'last_message_id' => $new_message->id]); } MessageSended::dispatch($new_message); diff --git a/app/Models/User.php b/app/Models/User.php index 3fcab18..a1da1a6 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -169,6 +169,14 @@ class User extends Authenticatable implements MustVerifyEmail } /** + * @param $query + * @return mixed + */ + public function scopeSuperAdmin($query) { + return $query->where('email', '=', config('admin.email'))->first(); + } + + /** * @throws JsonException */ public function getJobAttribute(): ?string diff --git a/app/Observers/MessageObserver.php b/app/Observers/MessageObserver.php new file mode 100644 index 0000000..c4299c8 --- /dev/null +++ b/app/Observers/MessageObserver.php @@ -0,0 +1,88 @@ +to_user_id; + $fromUserId = $message->user_id; + $toUser =User::query()->where('id',$toUserId)->first(); + $fromUser =User::query()->where('id',$fromUserId)->first(); + + + if ($toUser && !empty($toUser->subscribe_email) && $toUser->subscribe==1 ){ + + if ( (int) $message->ad_employer_id === 0 ){ + + Mail::to($toUser->subscribe_email)->send(new SendMessage($message,$fromUser)); + + }else{ + $vacancy=Ad_employer::find($message->ad_employer_id); + Mail::to($toUser->subscribe_email)->send(new SendVacancyMessage($message,$fromUser,$vacancy)); + + } + + } + } + + /** + * Handle the Message "updated" event. + * + * @param \App\Models\Message $message + * @return void + */ + public function updated(Message $message) + { + // + } + + /** + * Handle the Message "deleted" event. + * + * @param \App\Models\Message $message + * @return void + */ + public function deleted(Message $message) + { + // + } + + /** + * Handle the Message "restored" event. + * + * @param \App\Models\Message $message + * @return void + */ + public function restored(Message $message) + { + // + } + + /** + * Handle the Message "force deleted" event. + * + * @param \App\Models\Message $message + * @return void + */ + public function forceDeleted(Message $message) + { + // + } +} diff --git a/app/Observers/UserObserver.php b/app/Observers/UserObserver.php new file mode 100644 index 0000000..3f1cf2a --- /dev/null +++ b/app/Observers/UserObserver.php @@ -0,0 +1,74 @@ + $user->id, + 'to_user_id' => $superAdmin->id, + 'is_admin_chat' => 1, + 'is_removed' => 0, + ]); + } + + } + + /** + * Handle the User "updated" event. + * + * @param \App\Models\User $user + * @return void + */ + public function updated(User $user) + { + // + } + + /** + * Handle the User "deleted" event. + * + * @param \App\Models\User $user + * @return void + */ + public function deleted(User $user) + { + // + } + + /** + * Handle the User "restored" event. + * + * @param \App\Models\User $user + * @return void + */ + public function restored(User $user) + { + // + } + + /** + * Handle the User "force deleted" event. + * + * @param \App\Models\User $user + * @return void + */ + public function forceDeleted(User $user) + { + // + } +} diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index ae3ba48..99e7f13 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,6 +2,10 @@ namespace App\Providers; +use App\Models\Message; +use App\Models\User; +use App\Observers\MessageObserver; +use App\Observers\UserObserver; use Carbon\Carbon; use Illuminate\Auth\Notifications\VerifyEmail; use Illuminate\Notifications\Messages\MailMessage; @@ -36,6 +40,11 @@ class AppServiceProvider extends ServiceProvider ->subject('Подтвердите ваш адрес электронной почты!') ->view('emails.send_verify', ['url' => $verifyUrl]); }); + + Message::observe(MessageObserver::class); + User::observe(UserObserver::class); + + } } diff --git a/config/admin.php b/config/admin.php new file mode 100644 index 0000000..5f8f1eb --- /dev/null +++ b/config/admin.php @@ -0,0 +1,4 @@ + env('EMAIL_ADMIN'), +]; diff --git a/resources/views/chats/chats_list.blade.php b/resources/views/chats/chats_list.blade.php index 2808a64..f9ed4bd 100644 --- a/resources/views/chats/chats_list.blade.php +++ b/resources/views/chats/chats_list.blade.php @@ -10,7 +10,7 @@ Администратор сайта
- {{ $admin_chat->last_message->text }} + {{ $admin_chat->last_message?->text }}
@@ -18,8 +18,8 @@
{{ date(' H:i, d.m.Y', strtotime($admin_chat->created_at)) }}
- @if($admin_chat->admin_chat_unread_messages_count > 0) -
{{ $admin_chat->admin_chat_unread_messages_count }}
+ @if($admin_chat->unread_messages_count > 0) +
{{ $admin_chat->unread_messages_count }}
@endif
@@ -28,6 +28,7 @@ @if ($chats->count()) @foreach($chats as $chat) + @if(!$chat->is_admin_chat)
@@ -50,7 +51,7 @@
- {{ $chat->last_message->text ?? '' }} + {{ $chat->last_message?->text }}
@@ -74,6 +75,7 @@
+ @endif @endforeach
{{ $chats->onEachSide(0)->appends($_GET)->links('paginate') }} diff --git a/resources/views/emails/message.blade.php b/resources/views/emails/message.blade.php new file mode 100644 index 0000000..82eb210 --- /dev/null +++ b/resources/views/emails/message.blade.php @@ -0,0 +1,63 @@ + + + + + + BAIKALY + + + +
+ + Logo + + +

У вас новое личное сообщение!

+ +

+ Сообщение от {{$userName}}: +

+ + + {{ $text }} + + + + Ответить на сообщение + +
+ +
+ Это письмо отправлено автоматически. Пожалуйста, не отвечайте на него. +
+ + + Footer Logo + + +
+ + VK + + + Telegram + +
+ +
+ © 2024 — RekaMore.su +
+ + + diff --git a/resources/views/emails/message_vacancy.blade.php b/resources/views/emails/message_vacancy.blade.php new file mode 100644 index 0000000..1e71cee --- /dev/null +++ b/resources/views/emails/message_vacancy.blade.php @@ -0,0 +1,63 @@ + + + + + + BAIKALY + + + +
+ + Logo + + +

Отклик на вашу вакансию!

+ +

+ {{$userName}} откликнулся на вакансию "{{$vacancy}}" +

+ + + {{ $text }} + + + + Ответить на сообщение + +
+ +
+ Это письмо отправлено автоматически. Пожалуйста, не отвечайте на него. +
+ + + Footer Logo + + +
+ + VK + + + Telegram + +
+ +
+ © 2024 — RekaMore.su +
+ + + diff --git a/resources/views/employers/dialog.blade.php b/resources/views/employers/dialog.blade.php index ed070ff..74e27ce 100644 --- a/resources/views/employers/dialog.blade.php +++ b/resources/views/employers/dialog.blade.php @@ -86,7 +86,14 @@
- @if ($companion->is_worker) + @if($chat->is_admin_chat) +
+ @include('svg.logo_icon') +
+ Администратор сайта +
+
+ @elseif ($companion->is_worker)
@@ -151,51 +158,52 @@ @endif
- @if ($Messages->count()) + @if ($Messages->count()) @foreach ($Messages as $it) @if ($it->user_id == $companion->id)
-
- - - - - @if ($companion->is_worker) +
+ @if(!$companion->id == $superAdmin->id) + + + + @endif + @if($companion->is_worker) @if ((isset($companion->workers[0]->photo)) && (!empty($companion->workers[0]->photo))) @else @endif + @elseif($companion->id == $superAdmin->id) + @include('svg.logo_icon') @else @if ((isset($companion->employers[0]->logo)) && (!empty($companion->employers[0]->logo))) @else - +
+ + +
+ @endif @endif
- @if($it->text || $it->reply_message_id || $it->ad_employer_id > 0) + @if(\App\Models\Ad_employer::where('id', $it->ad_employer_id)->exists())
- @if($it->ad_employer_id > 0) - Отклик на вакансию "{{ \App\Models\Ad_employer::find($it->ad_employer_id)?->name }}"
- @if($it->text) - Комментарий: {{ $it->text }} - @endif - @else - @if($it->text) - {{ $it->text }} - @endif - @endif - - @if($it->reply_message_id) -
- {{ $it->reply_message->text }} -
+ Отклик на вакансию {{ \App\Models\Ad_employer::find($it->ad_employer_id)->name }} + @if($it->text) + Комментарий: {{ $it->text }} @endif
+ @else + @if($it->text) +
+ {{ $it->text }} +
+ @endif @endif @if ((isset($it->file)) && (!empty($it->file)))
@@ -218,11 +226,7 @@
@else
-
- - - - +
@if ($sender->is_worker) @if ((isset($sender->workers[0]->photo)) && (!empty($sender->workers[0]->photo))) @@ -230,7 +234,13 @@ @else @endif + @elseif($sender->id == $superAdmin->id) + @include('svg.logo_icon') @else + + + + @if ((isset($sender->employers[0]->logo)) && (!empty($sender->employers[0]->logo))) @@ -238,21 +248,36 @@ @endif @endif -
- @if($it->text) + @if($chat->is_admin_chat || $it->text || $it->reply_message_id || $it->ad_employer_id > 0)
- @if(\App\Models\Ad_employer::where('id', $it->ad_employer_id)->exists()) - Отклик на вакансию "{{ \App\Models\Ad_employer::find($it->ad_employer_id)->name }}"
- @if($it->text) - Комментарий: {{ $it->text }} - @endif + + @if($chat->is_admin_chat) + + @endif + + @if(\App\Models\Ad_employer::where('id', $it->ad_employer_id)->exists())) + Отклик на вакансию "{{ \App\Models\Ad_employer::find($it->ad_employer_id)->name }}"
+ @if($it->text) + Комментарий: {{ $it->text }} + @endif @else @if($it->text) {{ $it->text }} @endif - @endif
+ @endif + + @if($it->reply_message_id) +
+ {{ $it->reply_message->text }} +
+ @endif +
@endif @if ((isset($it->file)) && (!empty($it->file)))
diff --git a/resources/views/employers/subcribe.blade.php b/resources/views/employers/subcribe.blade.php index c3a867d..c0ed482 100644 --- a/resources/views/employers/subcribe.blade.php +++ b/resources/views/employers/subcribe.blade.php @@ -27,12 +27,15 @@
@include('messages_error')
-
+ @csrf

Укажите адрес электронной почты для получения уведомлений

- +
@@ -213,7 +213,7 @@ @else @if (App\Classes\StatusUser::Status() == 1) user()->workers[0]) >= 50) { + if (\App\Classes\Tools::getWorkerProfilePercent(Auth()->user()->workers[0]) >= 10) { $buttonId = 'ask_comment'; } else { $buttonId = 'ask_percent'; diff --git a/resources/views/workers/dialog.blade.php b/resources/views/workers/dialog.blade.php index e721b92..ad0d921 100644 --- a/resources/views/workers/dialog.blade.php +++ b/resources/views/workers/dialog.blade.php @@ -166,10 +166,12 @@ @foreach ($Messages as $it) @if ($it->user_id == $companion->id)
-
+
+ @if(!$companion->id == $supeAdmin->id) + @endif @if($companion->is_worker) @if ((isset($companion->workers[0]->photo)) && (!empty($companion->workers[0]->photo))) @@ -177,12 +179,18 @@ @else @endif + @elseif($companion->id == $supeAdmin->id) + @include('svg.logo_icon') @else @if ((isset($companion->employers[0]->logo)) && (!empty($companion->employers[0]->logo))) @else +
+ +
+ @endif @endif
@@ -196,7 +204,9 @@
@else @if($it->text) +
{{ $it->text }} +
@endif @endif @if ((isset($it->file)) && (!empty($it->file))) @@ -220,10 +230,8 @@
@else
-
- @if($chat->is_admin_chat) +
@include('svg.logo_icon') - @else @if ($sender->is_worker) @if ((isset($sender->workers[0]->photo)) && (!empty($sender->workers[0]->photo))) @@ -231,6 +239,10 @@ @else @endif + @elseif($sender->id == $supeAdmin->id) + + @include('svg.logo_icon') + @else @@ -243,18 +255,18 @@ @endif @endif - @endif
@if($chat->is_admin_chat || $it->text || $it->reply_message_id || $it->ad_employer_id > 0)
- @if($chat->is_admin_chat) - - @endif + +{{-- @if($chat->is_admin_chat)--}} +{{-- --}} +{{-- @endif--}} @if(\App\Models\Ad_employer::where('id', $it->ad_employer_id)->exists())) Отклик на вакансию "{{ \App\Models\Ad_employer::find($it->ad_employer_id)->name }}"
@@ -298,7 +310,7 @@ @endforeach @endif
- @if(!$chat->is_admin_chat) +
@csrf @@ -322,7 +334,6 @@
- @endif
diff --git a/resources/views/workers/menu.blade.php b/resources/views/workers/menu.blade.php index 22cc41f..dd553b1 100644 --- a/resources/views/workers/menu.blade.php +++ b/resources/views/workers/menu.blade.php @@ -50,6 +50,13 @@ Избранные вакансии + + + + + + Настройки уведомлений + Сменить пароль diff --git a/resources/views/workers/subcribe.blade.php b/resources/views/workers/subcribe.blade.php new file mode 100644 index 0000000..e749434 --- /dev/null +++ b/resources/views/workers/subcribe.blade.php @@ -0,0 +1,51 @@ +@extends('layout.frontend', ['title' => 'Настройка уведомлений - РекаМоре']) + +@section('scripts') + +@endsection + +@section('content') +
+
+ +
+
+ @include('workers.menu', ['item' => 11]) +
+ +
+
+

Настройки уведомлений

+
+ @include('messages_error') +
+
+ @csrf +

Укажите адрес электронной почты для получения уведомлений

+ + + +
+
+
+
+
+
+
+@endsection diff --git a/routes/web.php b/routes/web.php index 91ca206..fe40182 100644 --- a/routes/web.php +++ b/routes/web.php @@ -473,6 +473,9 @@ Route::group([ Route::post('cabinet/{worker}', [WorkerController::class, 'cabinet_save'])->name('cabinet_save'); Route::post('cabinet/cabinet_save_foto/{worker}', [WorkerController::class, 'cabinet_save_foto'])->name('cabinet_save_foto'); + Route::get('cabinet/subscribe', [WorkerController::class, 'subscribe'])->name('subscribe'); + Route::post('cabinet/subscribe/save', [WorkerController::class, 'save_subscribe'])->name('save_subscribe'); + // 2 страница - Сообщения Route::get('cabinet/messages/{type_message}', [WorkerController::class, 'messages'])->name('messages'); @@ -536,6 +539,7 @@ Route::group([ Route::get('cabinet/autolift', [WorkerController::class, 'resumeAutoLiftForm'])->name('autolift'); Route::post('cabinet/autolift/save', [WorkerController::class, 'resumeAutoLiftSave'])->name('autolift_save'); }); +Route::post('/admin/chat/response', [WorkerController::class, 'adminChatResponse'])->name('admin.chat.response'); // Личный кабинет работодателя Route::group([ @@ -621,7 +625,7 @@ Route::group([ // 11 страница - Настройка уведомлений Route::get('cabinet/subscribe', [EmployerController::class, 'subscribe'])->name('subscribe'); - Route::get('cabinet/subscribe/save', [EmployerController::class, 'save_subscribe'])->name('save_subscribe'); + Route::post('cabinet/subscribe/save', [EmployerController::class, 'save_subscribe'])->name('save_subscribe'); // 12 страница - Сменить пароль Route::get('cabinet/password-reset', [EmployerController::class, 'password_reset'])->name('password_reset'); -- 1.7.10.4