Commit 09a2fc9d81f0ca1b30ea802e4feba1517179fc45
1 parent
e14d394475
Exists in
master
messages and subscribe email
Showing 23 changed files with 854 additions and 93 deletions Side-by-side Diff
- app/Console/Commands/CreateAdminChat.php
- app/Console/Commands/RemoveOldUsers.php
- app/Http/Controllers/EmployerController.php
- app/Http/Controllers/WorkerController.php
- app/Mail/SendMessage.php
- app/Mail/SendVacancyMessage.php
- app/Models/Chat.php
- app/Models/Message.php
- app/Models/User.php
- app/Observers/MessageObserver.php
- app/Observers/UserObserver.php
- app/Providers/AppServiceProvider.php
- config/admin.php
- resources/views/chats/chats_list.blade.php
- resources/views/emails/message.blade.php
- resources/views/emails/message_vacancy.blade.php
- resources/views/employers/dialog.blade.php
- resources/views/employers/subcribe.blade.php
- resources/views/list_vacancies.blade.php
- resources/views/workers/dialog.blade.php
- resources/views/workers/menu.blade.php
- resources/views/workers/subcribe.blade.php
- routes/web.php
app/Console/Commands/CreateAdminChat.php
... | ... | @@ -0,0 +1,64 @@ |
1 | +<?php | |
2 | + | |
3 | +namespace App\Console\Commands; | |
4 | + | |
5 | +use App\Models\Chat; | |
6 | +use App\Models\User; | |
7 | +use Illuminate\Console\Command; | |
8 | + | |
9 | +class CreateAdminChat extends Command | |
10 | +{ | |
11 | + /** | |
12 | + * The name and signature of the console command. | |
13 | + * | |
14 | + * @var string | |
15 | + */ | |
16 | + protected $signature = 'admin:chat'; | |
17 | + | |
18 | + /** | |
19 | + * The console command description. | |
20 | + * | |
21 | + * @var string | |
22 | + */ | |
23 | + protected $description = 'Command description'; | |
24 | + | |
25 | + /** | |
26 | + * Execute the console command. | |
27 | + * | |
28 | + * @return int | |
29 | + */ | |
30 | + public function handle() | |
31 | + { | |
32 | + $superAdmin=User::superAdmin(); | |
33 | + | |
34 | + $users = User::where('id','!=',$superAdmin->id)->get(); | |
35 | + $chats = Chat::where('is_admin_chat', 1) | |
36 | + ->get(); | |
37 | + | |
38 | + foreach ($chats as $chat) { | |
39 | + $chat->delete(); | |
40 | + } | |
41 | + | |
42 | + $loopCount = $users->count(); | |
43 | + | |
44 | + if ($superAdmin){ | |
45 | + foreach ($users as $user){ | |
46 | + Chat::firstOrCreate([ | |
47 | + 'user_id' => $user->id, | |
48 | + 'to_user_id' => $superAdmin->id, | |
49 | + 'is_admin_chat' => 1, | |
50 | + 'is_removed' => 0, | |
51 | + ]); | |
52 | + | |
53 | + } | |
54 | + | |
55 | + $this->info("Admin chats created for {$loopCount} users." ); | |
56 | + | |
57 | + return Command::SUCCESS; | |
58 | + } | |
59 | + | |
60 | + $this->error("Admin is missing!" ); | |
61 | + | |
62 | + } | |
63 | + | |
64 | +} |
app/Console/Commands/RemoveOldUsers.php
... | ... | @@ -0,0 +1,105 @@ |
1 | +<?php | |
2 | + | |
3 | +namespace App\Console\Commands; | |
4 | + | |
5 | +use Illuminate\Console\Command; | |
6 | +use Illuminate\Support\Facades\DB; | |
7 | + | |
8 | +class RemoveOldUsers extends Command | |
9 | +{ | |
10 | + /** | |
11 | + * The name and signature of the console command. | |
12 | + * | |
13 | + * @var string | |
14 | + */ | |
15 | + protected $signature = 'users:remove-old'; | |
16 | + | |
17 | + /** | |
18 | + * The console command description. | |
19 | + * | |
20 | + * @var string | |
21 | + */ | |
22 | + protected $description = 'Remove old users and related data'; | |
23 | + | |
24 | + /** | |
25 | + * Execute the console command. | |
26 | + */ | |
27 | + public function handle() | |
28 | + { | |
29 | + $date = '2024-11-30 00:00:00'; | |
30 | + | |
31 | + $users = DB::table('users') | |
32 | + ->where('created_at', '<', $date) | |
33 | + ->pluck('id'); | |
34 | + | |
35 | + if ($users->isEmpty()) { | |
36 | + $this->info('No users to delete.'); | |
37 | + return 0; | |
38 | + } | |
39 | + | |
40 | + $this->info('Found ' . $users->count() . ' users to delete.'); | |
41 | + | |
42 | + $userRelatedTables = [ | |
43 | + 'answers', | |
44 | + 'chats', | |
45 | + 'employers', | |
46 | + 'group_users', | |
47 | + 'group_works', | |
48 | +// 'like_vacancy', | |
49 | +// 'like_worker', | |
50 | + 'media', | |
51 | + 'messages', | |
52 | + 'messages_requests', | |
53 | + 'static_workers', | |
54 | + 'workers', | |
55 | + ]; | |
56 | + | |
57 | + $workerEmployerRelatedTables = [ | |
58 | + 'ad_employers' => 'employer_id', | |
59 | + 'answers' => 'employer_id', | |
60 | + 'employers_mains' => 'employer_id', | |
61 | + 'employer_autolift_options' => 'employer_id', | |
62 | + 'flots' => 'employer_id', | |
63 | + 'place_works' => 'worker_id', | |
64 | + 'prev_company' => 'worker_id', | |
65 | + 'response_works' => 'worker_id', | |
66 | + 'sertifications' => 'worker_id', | |
67 | + 'title_workers' => 'worker_id', | |
68 | + 'worker_autolift_options' => 'worker_id', | |
69 | + ]; | |
70 | + | |
71 | + try { | |
72 | + DB::beginTransaction(); | |
73 | + | |
74 | + foreach ($userRelatedTables as $table) { | |
75 | + DB::table($table)->whereIn('user_id', $users)->delete(); | |
76 | + $this->info("Removed related records from table: $table"); | |
77 | + } | |
78 | + | |
79 | + $workerIds = DB::table('workers')->whereIn('user_id', $users)->pluck('id'); | |
80 | + $employerIds = DB::table('employers')->whereIn('user_id', $users)->pluck('id'); | |
81 | + | |
82 | + foreach ($workerEmployerRelatedTables as $table => $column) { | |
83 | + DB::table($table)->whereIn($column, str_contains($column, 'worker') ? $workerIds : $employerIds)->delete(); | |
84 | + $this->info("Removed related records for table: $table"); | |
85 | + } | |
86 | + foreach (['like_vacancy', 'like_worker'] as $table) { | |
87 | + DB::table($table)->whereIn('user_id', $users->map(fn($id) => (string)$id))->delete(); | |
88 | + DB::table($table)->whereIn('user_id', $users->map(fn($id) => (string)$id))->delete(); | |
89 | + $this->info("Removed related records from table: $table (VARCHAR user_id)"); | |
90 | + } | |
91 | + DB::table('workers')->whereIn('id', $workerIds)->delete(); | |
92 | + DB::table('employers')->whereIn('id', $employerIds)->delete(); | |
93 | + DB::table('users')->whereIn('id', $users)->delete(); | |
94 | + | |
95 | + DB::commit(); | |
96 | + $this->info('All related data and users have been removed successfully.'); | |
97 | + } catch (\Exception $e) { | |
98 | + DB::rollBack(); | |
99 | + $this->error('An error occurred: ' . $e->getMessage()); | |
100 | + } | |
101 | + | |
102 | + return 0; | |
103 | + } | |
104 | + | |
105 | +} |
app/Http/Controllers/EmployerController.php
... | ... | @@ -350,12 +350,12 @@ class EmployerController extends Controller |
350 | 350 | //Страницы сообщений список |
351 | 351 | public function messages($type_message) { |
352 | 352 | $user_id = Auth()->user()->id; |
353 | - | |
353 | + $superAdmin =User_Model::superAdmin(); | |
354 | 354 | $chats = Chat::get_user_chats($user_id); |
355 | + $admin_chat = Chat::get_user_admin_chat($user_id); | |
355 | 356 | $user_type = 'employer'; |
356 | - $admin_chat = false; | |
357 | 357 | |
358 | - return view('employers.messages', compact('chats', 'admin_chat', 'user_id', 'user_type')); | |
358 | + return view('employers.messages', compact('chats', 'admin_chat', 'user_id', 'user_type','superAdmin')); | |
359 | 359 | } |
360 | 360 | |
361 | 361 | // Диалог между пользователями |
... | ... | @@ -366,6 +366,7 @@ class EmployerController extends Controller |
366 | 366 | } else { |
367 | 367 | $ad_employer = 0; |
368 | 368 | } |
369 | + $superAdmin =User_Model::superAdmin(); | |
369 | 370 | |
370 | 371 | $sender = User_Model::query()->with('workers')->with('employers')->where('id', $chat->user_id)->first(); |
371 | 372 | $companion = User_Model::query()->with('workers')->with('employers')->where('id', $chat->to_user_id)->first(); |
... | ... | @@ -374,7 +375,7 @@ class EmployerController extends Controller |
374 | 375 | |
375 | 376 | Message::where('user_id', '=', $chat->to_user_id)->where('to_user_id', '=', $chat->user_id)->update(['flag_new' => 0]); |
376 | 377 | |
377 | - return view('employers.dialog', compact('companion', 'sender', 'ad_employer', 'Messages')); | |
378 | + return view('employers.dialog', compact('companion', 'sender', 'ad_employer', 'Messages','chat','superAdmin')); | |
378 | 379 | } |
379 | 380 | |
380 | 381 | public function pin_chat(Request $request){ |
... | ... | @@ -610,13 +611,20 @@ class EmployerController extends Controller |
610 | 611 | |
611 | 612 | //Установка уведомлений сохранение |
612 | 613 | public function save_subscribe(Request $request) { |
613 | -// dd($request->all()); | |
614 | + | |
614 | 615 | $msg = $request->validate([ |
615 | - 'subscribe_email' => 'required|email|min:5|max:255', | |
616 | - ]); | |
616 | + 'email' => 'required|email|min:5|max:255', | |
617 | + ]); | |
618 | + $user= Auth::user(); | |
619 | + | |
620 | + User_Model::updateOrCreate( | |
621 | + ['id' => $user->id], | |
622 | + ['subscribe_email' => $request->email, | |
623 | + 'subscribe' => request()->has('email_msg') && request('email_msg') === 'on' ? 1 : 0 | |
624 | + ] | |
625 | + ); | |
617 | 626 | return redirect()->route('employer.subscribe')->with('Вы успешно подписались на рассылку'); |
618 | 627 | } |
619 | - | |
620 | 628 | //Сбросить форму с паролем |
621 | 629 | public function password_reset() { |
622 | 630 | $email = Auth()->user()->email; |
app/Http/Controllers/WorkerController.php
... | ... | @@ -772,7 +772,11 @@ class WorkerController extends Controller |
772 | 772 | 'Job_title')); |
773 | 773 | |
774 | 774 | } |
775 | - | |
775 | + public function pin_chat(Request $request){ | |
776 | + $chat_id = $request->get('id'); | |
777 | + $is_fixed = $request->get('is_fixed'); | |
778 | + Chat::pin_chat($chat_id, $is_fixed); | |
779 | + } | |
776 | 780 | //Переписка |
777 | 781 | public function dialog(Chat $chat, Request $request) { |
778 | 782 | // Получение параметров. |
... | ... | @@ -781,7 +785,7 @@ class WorkerController extends Controller |
781 | 785 | } else { |
782 | 786 | $ad_employer = 0; |
783 | 787 | } |
784 | - | |
788 | + $supeAdmin=User::superAdmin(); | |
785 | 789 | $sender = User_Model::query()->with('workers')->with('employers')->where('id', $chat->user_id)->first(); |
786 | 790 | $companion = User_Model::query()->with('workers')->with('employers')->where('id', $chat->to_user_id)->first(); |
787 | 791 | |
... | ... | @@ -789,7 +793,7 @@ class WorkerController extends Controller |
789 | 793 | |
790 | 794 | Message::where('chat_id_to', '=', $chat->id)->update(['flag_new' => 0]); |
791 | 795 | |
792 | - return view('workers.dialog', compact('companion', 'sender', 'chat', 'Messages', 'ad_employer')); | |
796 | + return view('workers.dialog', compact('companion', 'sender', 'chat', 'Messages', 'ad_employer','supeAdmin')); | |
793 | 797 | } |
794 | 798 | |
795 | 799 | // Даунылоады |
... | ... | @@ -889,7 +893,30 @@ class WorkerController extends Controller |
889 | 893 | |
890 | 894 | return redirect()->route('worker.additional_documents')->with('success', 'Успешно сохранено!'); |
891 | 895 | } |
896 | + public function subscribe() { | |
897 | + | |
898 | + $user= Auth::user(); | |
899 | + return view('workers.subcribe',compact('user')); | |
900 | + } | |
901 | + | |
902 | + //Установка уведомлений сохранение | |
903 | + public function save_subscribe(Request $request) { | |
892 | 904 | |
905 | + $msg = $request->validate([ | |
906 | + 'email' => 'required|email|min:5|max:255', | |
907 | + ]); | |
908 | + | |
909 | + $user= Auth::user(); | |
910 | + | |
911 | + User_Model::updateOrCreate( | |
912 | + ['id' => $user->id], | |
913 | + ['subscribe_email' => $request->email, | |
914 | + 'subscribe' => request()->has('email_msg') && request('email_msg') === 'on' ? 1 : 0 | |
915 | + ] | |
916 | + ); | |
917 | + return redirect()->route('worker.subscribe')->with('Вы успешно подписались на рассылку'); | |
918 | + | |
919 | + } | |
893 | 920 | public function delete_add_diplom(Request $request, Worker $worker) { |
894 | 921 | $infoblok_id = $request->get('infoblok_id'); |
895 | 922 |
app/Mail/SendMessage.php
... | ... | @@ -0,0 +1,72 @@ |
1 | +<?php | |
2 | + | |
3 | +namespace App\Mail; | |
4 | + | |
5 | +use Illuminate\Bus\Queueable; | |
6 | +use Illuminate\Contracts\Queue\ShouldQueue; | |
7 | +use Illuminate\Mail\Mailable; | |
8 | +use Illuminate\Mail\Mailables\Content; | |
9 | +use Illuminate\Mail\Mailables\Envelope; | |
10 | +use Illuminate\Queue\SerializesModels; | |
11 | + | |
12 | +class SendMessage extends Mailable implements ShouldQueue | |
13 | +{ | |
14 | + use Queueable, SerializesModels; | |
15 | + | |
16 | + public $messageText; | |
17 | + public $userName; | |
18 | + public $link; | |
19 | + /** | |
20 | + * Create a new message instance. | |
21 | + * | |
22 | + * @return void | |
23 | + */ | |
24 | + public function __construct($message,$user) | |
25 | + { | |
26 | + | |
27 | + $this->messageText = $message->text; | |
28 | + $this->userName = $user->name; | |
29 | + $this->link = route('employer.dialog', ['chat' => $message->chat_id_from]); | |
30 | + | |
31 | + } | |
32 | + | |
33 | + /** | |
34 | + * Get the message envelope. | |
35 | + * | |
36 | + * @return \Illuminate\Mail\Mailables\Envelope | |
37 | + */ | |
38 | + public function envelope() | |
39 | + { | |
40 | + return new Envelope( | |
41 | + subject: 'У вас новое личное сообщение!', | |
42 | + ); | |
43 | + } | |
44 | + | |
45 | + /** | |
46 | + * Get the message content definition. | |
47 | + * | |
48 | + * @return \Illuminate\Mail\Mailables\Content | |
49 | + */ | |
50 | + public function content() | |
51 | + { | |
52 | + | |
53 | + return new Content( | |
54 | + view: 'emails.message', | |
55 | + with: [ | |
56 | + 'text' => $this->messageText, | |
57 | + 'userName' => $this->userName, | |
58 | + 'link' => $this->link, | |
59 | + ], | |
60 | + ); | |
61 | + } | |
62 | + | |
63 | + /** | |
64 | + * Get the attachments for the message. | |
65 | + * | |
66 | + * @return array | |
67 | + */ | |
68 | + public function attachments() | |
69 | + { | |
70 | + return []; | |
71 | + } | |
72 | +} |
app/Mail/SendVacancyMessage.php
... | ... | @@ -0,0 +1,75 @@ |
1 | +<?php | |
2 | + | |
3 | +namespace App\Mail; | |
4 | + | |
5 | +use Illuminate\Bus\Queueable; | |
6 | +use Illuminate\Contracts\Queue\ShouldQueue; | |
7 | +use Illuminate\Mail\Mailable; | |
8 | +use Illuminate\Mail\Mailables\Content; | |
9 | +use Illuminate\Mail\Mailables\Envelope; | |
10 | +use Illuminate\Queue\SerializesModels; | |
11 | + | |
12 | +class SendVacancyMessage extends Mailable implements ShouldQueue | |
13 | +{ | |
14 | + use Queueable, SerializesModels; | |
15 | + | |
16 | + public $messageText; | |
17 | + public $userName; | |
18 | + public $link; | |
19 | + public $vacancy; | |
20 | + /** | |
21 | + * Create a new message instance. | |
22 | + * | |
23 | + * @return void | |
24 | + */ | |
25 | + public function __construct($message,$user,$vacancy) | |
26 | + { | |
27 | + | |
28 | + $this->messageText = $message->text; | |
29 | + $this->userName = $user->name; | |
30 | + $this->vacancy = $vacancy->name; | |
31 | + $this->link = route('employer.dialog', ['chat' => $message->chat_id_from]); | |
32 | + | |
33 | + } | |
34 | + | |
35 | + /** | |
36 | + * Get the message envelope. | |
37 | + * | |
38 | + * @return \Illuminate\Mail\Mailables\Envelope | |
39 | + */ | |
40 | + public function envelope() | |
41 | + { | |
42 | + return new Envelope( | |
43 | + subject: 'Отклик на вашу вакансию!', | |
44 | + ); | |
45 | + } | |
46 | + | |
47 | + /** | |
48 | + * Get the message content definition. | |
49 | + * | |
50 | + * @return \Illuminate\Mail\Mailables\Content | |
51 | + */ | |
52 | + public function content() | |
53 | + { | |
54 | + | |
55 | + return new Content( | |
56 | + view: 'emails.message_vacancy', | |
57 | + with: [ | |
58 | + 'text' => $this->messageText, | |
59 | + 'userName' => $this->userName, | |
60 | + 'link' => $this->link, | |
61 | + 'vacancy' => $this->vacancy, | |
62 | + ], | |
63 | + ); | |
64 | + } | |
65 | + | |
66 | + /** | |
67 | + * Get the attachments for the message. | |
68 | + * | |
69 | + * @return array | |
70 | + */ | |
71 | + public function attachments() | |
72 | + { | |
73 | + return []; | |
74 | + } | |
75 | +} |
app/Models/Chat.php
... | ... | @@ -49,6 +49,7 @@ class Chat extends Model |
49 | 49 | |
50 | 50 | public static function pin_chat(int $chat_id, $fixed) |
51 | 51 | { |
52 | + | |
52 | 53 | return self::where('id', '=', $chat_id) |
53 | 54 | ->update([ |
54 | 55 | 'is_fixed' => !empty($fixed) ? 1 : 0, |
... | ... | @@ -88,24 +89,17 @@ class Chat extends Model |
88 | 89 | { |
89 | 90 | return Chat::query() |
90 | 91 | ->with('last_message') |
91 | - ->withCount(['admin_chat_unread_messages' => function ($query) use($user_id) { | |
92 | - $query->whereNull('chat_id_from')->where('to_user_id', '=', $user_id)->where('flag_new', '=', 1); | |
92 | + ->withCount(['unread_messages' => function ($query) use($user_id) { | |
93 | + $query->where('to_user_id', '=', $user_id)->where('flag_new', '=', 1); | |
93 | 94 | }]) |
94 | - ->where('to_user_id', '=', $user_id) | |
95 | + ->where('user_id', '=', $user_id) | |
95 | 96 | ->where('is_admin_chat', 1) |
96 | 97 | ->first() |
97 | 98 | ; |
98 | 99 | } |
99 | 100 | |
100 | 101 | public static function get_chat_messages(Chat $chat){ |
101 | - if ($chat->is_admin_chat){ | |
102 | - return Message::query() | |
103 | - ->where('chat_id_to', $chat->id) | |
104 | - ->where('to_user_id', $chat->to_user_id) | |
105 | - ->orderBy('created_at') | |
106 | - ->get() | |
107 | - ; | |
108 | - } else { | |
102 | + | |
109 | 103 | return Message::query() |
110 | 104 | ->where(function ($query) use ($chat) { |
111 | 105 | $query->where('chat_id_from', $chat->id)->orWhere('chat_id_to', $chat->id); |
... | ... | @@ -123,7 +117,6 @@ class Chat extends Model |
123 | 117 | ->OrderBy('created_at') |
124 | 118 | ->get() |
125 | 119 | ; |
126 | - } | |
127 | 120 | } |
128 | 121 | |
129 | 122 | } |
app/Models/Message.php
... | ... | @@ -56,6 +56,14 @@ class Message extends Model |
56 | 56 | string $file_store_path = '/', |
57 | 57 | bool $is_admin_chat = false |
58 | 58 | ) { |
59 | + | |
60 | + $superAdmin =User::superAdmin(); | |
61 | + | |
62 | + if ($superAdmin && $superAdmin->id == $to_user_id ){ | |
63 | + | |
64 | + $is_admin_chat=true; | |
65 | + } | |
66 | + | |
59 | 67 | $message_params['user_id'] = $user_id; |
60 | 68 | $message_params['to_user_id'] = $to_user_id; |
61 | 69 | $files = $request->file(); |
... | ... | @@ -66,21 +74,20 @@ class Message extends Model |
66 | 74 | } |
67 | 75 | |
68 | 76 | $chat_form = Chat::firstOrCreate([ |
69 | - 'user_id' => $is_admin_chat ? 0 : $user_id, | |
77 | + 'user_id' => $user_id, | |
70 | 78 | 'to_user_id' => $to_user_id, |
71 | 79 | 'is_removed' => 0, |
72 | 80 | 'is_admin_chat' => $is_admin_chat ? 1 : 0, |
73 | 81 | ]); |
74 | - $message_params[$is_admin_chat ? 'chat_id_to' : 'chat_id_from'] = $chat_form->id; | |
82 | + $message_params['chat_id_from'] = $chat_form->id; | |
83 | + | |
75 | 84 | |
76 | - if (!$is_admin_chat) { | |
77 | 85 | $chat_to = Chat::firstOrCreate([ |
78 | 86 | 'user_id' => $to_user_id, |
79 | 87 | 'to_user_id' => $user_id, |
80 | - 'is_removed' => 0 | |
88 | + 'is_removed' => 0, | |
81 | 89 | ]); |
82 | 90 | $message_params['chat_id_to'] = $chat_to->id; |
83 | - } | |
84 | 91 | |
85 | 92 | //dump('before creation '.$message_params['text']); |
86 | 93 | $new_message = Message::create($message_params); |
... | ... | @@ -89,9 +96,7 @@ class Message extends Model |
89 | 96 | if ($new_message->id > $chat_form->last_message_id) { |
90 | 97 | $chat_form->update(['last_message_date' => date("Y-m-d H:i:s"), 'last_message_id' => $new_message->id]); |
91 | 98 | |
92 | - if (!$is_admin_chat) { | |
93 | - $chat_to->update(['last_message_date' => date("Y-m-d H:i:s"), 'last_message_id' => $new_message->id]); | |
94 | - } | |
99 | + $chat_to->update(['last_message_date' => date("Y-m-d H:i:s"), 'last_message_id' => $new_message->id]); | |
95 | 100 | } |
96 | 101 | MessageSended::dispatch($new_message); |
97 | 102 |
app/Models/User.php
... | ... | @@ -169,6 +169,14 @@ class User extends Authenticatable implements MustVerifyEmail |
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
172 | + * @param $query | |
173 | + * @return mixed | |
174 | + */ | |
175 | + public function scopeSuperAdmin($query) { | |
176 | + return $query->where('email', '=', config('admin.email'))->first(); | |
177 | + } | |
178 | + | |
179 | + /** | |
172 | 180 | * @throws JsonException |
173 | 181 | */ |
174 | 182 | public function getJobAttribute(): ?string |
app/Observers/MessageObserver.php
... | ... | @@ -0,0 +1,88 @@ |
1 | +<?php | |
2 | + | |
3 | +namespace App\Observers; | |
4 | + | |
5 | +use App\Mail\SendMessage; | |
6 | +use App\Mail\SendVacancyMessage; | |
7 | +use App\Models\Ad_employer; | |
8 | +use App\Models\Message; | |
9 | +use App\Models\User; | |
10 | +use Illuminate\Support\Facades\Mail; | |
11 | + | |
12 | +class MessageObserver | |
13 | +{ | |
14 | + | |
15 | + /** | |
16 | + * Handle the Message "created" event. | |
17 | + * | |
18 | + * @param \App\Models\Message $message | |
19 | + * @return void | |
20 | + */ | |
21 | + public function created(Message $message) | |
22 | + { | |
23 | + | |
24 | + $toUserId = $message->to_user_id; | |
25 | + $fromUserId = $message->user_id; | |
26 | + $toUser =User::query()->where('id',$toUserId)->first(); | |
27 | + $fromUser =User::query()->where('id',$fromUserId)->first(); | |
28 | + | |
29 | + | |
30 | + if ($toUser && !empty($toUser->subscribe_email) && $toUser->subscribe==1 ){ | |
31 | + | |
32 | + if ( (int) $message->ad_employer_id === 0 ){ | |
33 | + | |
34 | + Mail::to($toUser->subscribe_email)->send(new SendMessage($message,$fromUser)); | |
35 | + | |
36 | + }else{ | |
37 | + $vacancy=Ad_employer::find($message->ad_employer_id); | |
38 | + Mail::to($toUser->subscribe_email)->send(new SendVacancyMessage($message,$fromUser,$vacancy)); | |
39 | + | |
40 | + } | |
41 | + | |
42 | + } | |
43 | + } | |
44 | + | |
45 | + /** | |
46 | + * Handle the Message "updated" event. | |
47 | + * | |
48 | + * @param \App\Models\Message $message | |
49 | + * @return void | |
50 | + */ | |
51 | + public function updated(Message $message) | |
52 | + { | |
53 | + // | |
54 | + } | |
55 | + | |
56 | + /** | |
57 | + * Handle the Message "deleted" event. | |
58 | + * | |
59 | + * @param \App\Models\Message $message | |
60 | + * @return void | |
61 | + */ | |
62 | + public function deleted(Message $message) | |
63 | + { | |
64 | + // | |
65 | + } | |
66 | + | |
67 | + /** | |
68 | + * Handle the Message "restored" event. | |
69 | + * | |
70 | + * @param \App\Models\Message $message | |
71 | + * @return void | |
72 | + */ | |
73 | + public function restored(Message $message) | |
74 | + { | |
75 | + // | |
76 | + } | |
77 | + | |
78 | + /** | |
79 | + * Handle the Message "force deleted" event. | |
80 | + * | |
81 | + * @param \App\Models\Message $message | |
82 | + * @return void | |
83 | + */ | |
84 | + public function forceDeleted(Message $message) | |
85 | + { | |
86 | + // | |
87 | + } | |
88 | +} |
app/Observers/UserObserver.php
... | ... | @@ -0,0 +1,74 @@ |
1 | +<?php | |
2 | + | |
3 | +namespace App\Observers; | |
4 | + | |
5 | +use App\Models\Chat; | |
6 | +use App\Models\User; | |
7 | + | |
8 | +class UserObserver | |
9 | +{ | |
10 | + /** | |
11 | + * Handle the User "created" event. | |
12 | + * | |
13 | + * @param \App\Models\User $user | |
14 | + * @return void | |
15 | + */ | |
16 | + public function created(User $user) | |
17 | + { | |
18 | + $superAdmin= User::superAdmin(); | |
19 | + | |
20 | + if ($superAdmin){ | |
21 | + Chat::firstOrCreate([ | |
22 | + 'user_id' => $user->id, | |
23 | + 'to_user_id' => $superAdmin->id, | |
24 | + 'is_admin_chat' => 1, | |
25 | + 'is_removed' => 0, | |
26 | + ]); | |
27 | + } | |
28 | + | |
29 | + } | |
30 | + | |
31 | + /** | |
32 | + * Handle the User "updated" event. | |
33 | + * | |
34 | + * @param \App\Models\User $user | |
35 | + * @return void | |
36 | + */ | |
37 | + public function updated(User $user) | |
38 | + { | |
39 | + // | |
40 | + } | |
41 | + | |
42 | + /** | |
43 | + * Handle the User "deleted" event. | |
44 | + * | |
45 | + * @param \App\Models\User $user | |
46 | + * @return void | |
47 | + */ | |
48 | + public function deleted(User $user) | |
49 | + { | |
50 | + // | |
51 | + } | |
52 | + | |
53 | + /** | |
54 | + * Handle the User "restored" event. | |
55 | + * | |
56 | + * @param \App\Models\User $user | |
57 | + * @return void | |
58 | + */ | |
59 | + public function restored(User $user) | |
60 | + { | |
61 | + // | |
62 | + } | |
63 | + | |
64 | + /** | |
65 | + * Handle the User "force deleted" event. | |
66 | + * | |
67 | + * @param \App\Models\User $user | |
68 | + * @return void | |
69 | + */ | |
70 | + public function forceDeleted(User $user) | |
71 | + { | |
72 | + // | |
73 | + } | |
74 | +} |
app/Providers/AppServiceProvider.php
... | ... | @@ -2,6 +2,10 @@ |
2 | 2 | |
3 | 3 | namespace App\Providers; |
4 | 4 | |
5 | +use App\Models\Message; | |
6 | +use App\Models\User; | |
7 | +use App\Observers\MessageObserver; | |
8 | +use App\Observers\UserObserver; | |
5 | 9 | use Carbon\Carbon; |
6 | 10 | use Illuminate\Auth\Notifications\VerifyEmail; |
7 | 11 | use Illuminate\Notifications\Messages\MailMessage; |
... | ... | @@ -36,6 +40,11 @@ class AppServiceProvider extends ServiceProvider |
36 | 40 | ->subject('Подтвердите ваш адрес электронной почты!') |
37 | 41 | ->view('emails.send_verify', ['url' => $verifyUrl]); |
38 | 42 | }); |
43 | + | |
44 | + Message::observe(MessageObserver::class); | |
45 | + User::observe(UserObserver::class); | |
46 | + | |
47 | + | |
39 | 48 | } |
40 | 49 | |
41 | 50 | } |
config/admin.php
resources/views/chats/chats_list.blade.php
... | ... | @@ -10,7 +10,7 @@ |
10 | 10 | <b>Администратор сайта</b> |
11 | 11 | </div> |
12 | 12 | <div> |
13 | - {{ $admin_chat->last_message->text }} | |
13 | + {{ $admin_chat->last_message?->text }} | |
14 | 14 | </div> |
15 | 15 | </div> |
16 | 16 | </a> |
... | ... | @@ -18,8 +18,8 @@ |
18 | 18 | <div class="messages__item-actions" data-chat-id="{{ $admin_chat->id }}"> |
19 | 19 | <div class="messages__item-date max-content">{{ date(' H:i, d.m.Y', strtotime($admin_chat->created_at)) }}</div> |
20 | 20 | <div class="messages__item-buttons"> |
21 | - @if($admin_chat->admin_chat_unread_messages_count > 0) | |
22 | - <div class="unread-messages-count mr-15">{{ $admin_chat->admin_chat_unread_messages_count }}</div> | |
21 | + @if($admin_chat->unread_messages_count > 0) | |
22 | + <div class="unread-messages-count mr-15">{{ $admin_chat->unread_messages_count }}</div> | |
23 | 23 | @endif |
24 | 24 | </div> |
25 | 25 | </div> |
... | ... | @@ -28,6 +28,7 @@ |
28 | 28 | |
29 | 29 | @if ($chats->count()) |
30 | 30 | @foreach($chats as $chat) |
31 | + @if(!$chat->is_admin_chat) | |
31 | 32 | <div class="messages__item hover-shadow {{ intval($chat->is_fixed) == 1 ? 'chat-fixed' : '' }}"> |
32 | 33 | <a class="messages__item-info" href="{{ route($user_type . '.dialog', ['chat' => $chat->id]) }}"> |
33 | 34 | <div class="messages__item-photo"> |
... | ... | @@ -50,7 +51,7 @@ |
50 | 51 | </b> |
51 | 52 | </div> |
52 | 53 | <div> |
53 | - {{ $chat->last_message->text ?? '' }} | |
54 | + {{ $chat->last_message?->text }} | |
54 | 55 | </div> |
55 | 56 | </div> |
56 | 57 | </a> |
... | ... | @@ -74,6 +75,7 @@ |
74 | 75 | <div class="clear"></div> |
75 | 76 | </div> |
76 | 77 | </div> |
78 | + @endif | |
77 | 79 | @endforeach |
78 | 80 | <div style="margin-top: 20px"> |
79 | 81 | {{ $chats->onEachSide(0)->appends($_GET)->links('paginate') }} |
resources/views/emails/message.blade.php
... | ... | @@ -0,0 +1,63 @@ |
1 | +<!DOCTYPE html> | |
2 | +<html lang="ru"> | |
3 | + | |
4 | +<head> | |
5 | + <meta charset="utf-8"> | |
6 | + <title>BAIKALY</title> | |
7 | +</head> | |
8 | + | |
9 | +<body style="background: #eff2fb; padding: 50px 0; margin: 0; font-family: Arial, sans-serif;"> | |
10 | +<div style="background: #fff url({{asset('images/emails/23.png')}}) no-repeat 100% 100%; | |
11 | + border: 1px solid #377d87; border-radius: 10px; max-width: 600px; | |
12 | + margin: 0 auto; margin-top: 32px; padding: 60px; text-align: center;"> | |
13 | + <a href="{{config('app.url')}}" target="_blank" style="display: block; margin: 0 auto;"> | |
14 | + <img src="{{asset('images/emails/20.png')}}" alt="Logo" | |
15 | + style="width: 182px; height: 54px; display: block; margin: 0 auto;"> | |
16 | + </a> | |
17 | + | |
18 | + <p style="font-size: 20px; color: #377d87; margin-bottom: 16px;">У вас новое личное сообщение!</p> | |
19 | + | |
20 | + <p style="font-size: 18px; color: #555; margin-top: 16px; margin-bottom: 32px;"> | |
21 | + Сообщение от <strong style="color: #333;">{{$userName}}</strong>: | |
22 | + </p> | |
23 | + | |
24 | + <b style="font-size: 24px; line-height: 32px; display: block; margin: 32px 0; color: #000; word-wrap: break-word; overflow-wrap: break-word; max-width: 100%; text-align: left;"> | |
25 | + {{ $text }} | |
26 | + </b> | |
27 | + | |
28 | + <a href="{{ $link }}" target="_blank" | |
29 | + style="display: inline-block; background-color: #377d87; color: #ffffff; text-decoration: none; padding: 12px 20px; font-size: 16px; font-weight: bold; border-radius: 8px; margin-top: 20px; cursor: pointer;"> | |
30 | + Ответить на сообщение | |
31 | + </a> | |
32 | +</div> | |
33 | + | |
34 | +<div style="margin: 32px 0; font-style: italic; font-size: 14px; | |
35 | + line-height: 20px; color: #37393a; text-align: center;"> | |
36 | + Это письмо отправлено автоматически. Пожалуйста, не отвечайте на него. | |
37 | +</div> | |
38 | + | |
39 | +<a href="{{config('app.url')}}" target="_blank" style="display: block; margin: 0 auto;"> | |
40 | + <img src="{{asset('images/emails/19.png')}}" alt="Footer Logo" | |
41 | + style="width: 222px; height: 74px; display: block; margin: 0 auto;"> | |
42 | +</a> | |
43 | + | |
44 | +<div style="display: block; text-align: center; margin-top: 56px; font-size: 0;"> | |
45 | + <a href="https://vk.com/rekamore_su" target="_blank" | |
46 | + style="display: inline-block; vertical-align: middle; margin: 0 4px;"> | |
47 | + <img src="{{asset('images/emails/22.png')}}" alt="VK" | |
48 | + style="width: 40px; height: 40px;"> | |
49 | + </a> | |
50 | + <a href="https://t.me/rekamore_su" target="_blank" | |
51 | + style="display: inline-block; vertical-align: middle; margin: 0 4px;"> | |
52 | + <img src="{{asset('images/emails/21.png')}}" alt="Telegram" | |
53 | + style="width: 40px; height: 40px;"> | |
54 | + </a> | |
55 | +</div> | |
56 | + | |
57 | +<div style="font-family: Arial, sans-serif; color: #37393a; text-align: center; | |
58 | + margin-top: 24px; font-size: 14px; line-height: 20px; margin-bottom: 32px;"> | |
59 | + © 2024 — RekaMore.su | |
60 | +</div> | |
61 | +</body> | |
62 | + | |
63 | +</html> |
resources/views/emails/message_vacancy.blade.php
... | ... | @@ -0,0 +1,63 @@ |
1 | +<!DOCTYPE html> | |
2 | +<html lang="ru"> | |
3 | + | |
4 | +<head> | |
5 | + <meta charset="utf-8"> | |
6 | + <title>BAIKALY</title> | |
7 | +</head> | |
8 | + | |
9 | +<body style="background: #eff2fb; padding: 50px 0; margin: 0; font-family: Arial, sans-serif;"> | |
10 | +<div style="background: #fff url({{asset('images/emails/23.png')}}) no-repeat 100% 100%; | |
11 | + border: 1px solid #377d87; border-radius: 10px; max-width: 600px; | |
12 | + margin: 0 auto; margin-top: 32px; padding: 60px; text-align: center;"> | |
13 | + <a href="{{config('app.url')}}" target="_blank" style="display: block; margin: 0 auto;"> | |
14 | + <img src="{{asset('images/emails/20.png')}}" alt="Logo" | |
15 | + style="width: 182px; height: 54px; display: block; margin: 0 auto;"> | |
16 | + </a> | |
17 | + | |
18 | + <p style="font-size: 20px; color: #377d87; margin-bottom: 16px;">Отклик на вашу вакансию!</p> | |
19 | + | |
20 | + <p style="font-size: 18px; color: #555; margin-top: 16px; margin-bottom: 32px;"> | |
21 | + <strong style="color: #333;">{{$userName}}</strong> откликнулся на вакансию "{{$vacancy}}" | |
22 | + </p> | |
23 | + | |
24 | + <b style="font-size: 24px; line-height: 32px; display: block; margin: 32px 0; color: #000; word-wrap: break-word; overflow-wrap: break-word; max-width: 100%; text-align: left;"> | |
25 | + {{ $text }} | |
26 | + </b> | |
27 | + | |
28 | + <a href="{{ $link }}" target="_blank" | |
29 | + style="display: inline-block; background-color: #377d87; color: #ffffff; text-decoration: none; padding: 12px 20px; font-size: 16px; font-weight: bold; border-radius: 8px; margin-top: 20px; cursor: pointer;"> | |
30 | + Ответить на сообщение | |
31 | + </a> | |
32 | +</div> | |
33 | + | |
34 | +<div style="margin: 32px 0; font-style: italic; font-size: 14px; | |
35 | + line-height: 20px; color: #37393a; text-align: center;"> | |
36 | + Это письмо отправлено автоматически. Пожалуйста, не отвечайте на него. | |
37 | +</div> | |
38 | + | |
39 | +<a href="{{config('app.url')}}" target="_blank" style="display: block; margin: 0 auto;"> | |
40 | + <img src="{{asset('images/emails/19.png')}}" alt="Footer Logo" | |
41 | + style="width: 222px; height: 74px; display: block; margin: 0 auto;"> | |
42 | +</a> | |
43 | + | |
44 | +<div style="display: block; text-align: center; margin-top: 56px; font-size: 0;"> | |
45 | + <a href="https://vk.com/rekamore_su" target="_blank" | |
46 | + style="display: inline-block; vertical-align: middle; margin: 0 4px;"> | |
47 | + <img src="{{asset('images/emails/22.png')}}" alt="VK" | |
48 | + style="width: 40px; height: 40px;"> | |
49 | + </a> | |
50 | + <a href="https://t.me/rekamore_su" target="_blank" | |
51 | + style="display: inline-block; vertical-align: middle; margin: 0 4px;"> | |
52 | + <img src="{{asset('images/emails/21.png')}}" alt="Telegram" | |
53 | + style="width: 40px; height: 40px;"> | |
54 | + </a> | |
55 | +</div> | |
56 | + | |
57 | +<div style="font-family: Arial, sans-serif; color: #37393a; text-align: center; | |
58 | + margin-top: 24px; font-size: 14px; line-height: 20px; margin-bottom: 32px;"> | |
59 | + © 2024 — RekaMore.su | |
60 | +</div> | |
61 | +</body> | |
62 | + | |
63 | +</html> |
resources/views/employers/dialog.blade.php
... | ... | @@ -86,7 +86,14 @@ |
86 | 86 | </a> |
87 | 87 | <div class="chatbox"> |
88 | 88 | <div class="chatbox__toper"> |
89 | - @if ($companion->is_worker) | |
89 | + @if($chat->is_admin_chat) | |
90 | + <div class="chatbox__toper-info messages__item-info"> | |
91 | + @include('svg.logo_icon') | |
92 | + <div class="messages__item-text bold font20"> | |
93 | + Администратор сайта | |
94 | + </div> | |
95 | + </div> | |
96 | + @elseif ($companion->is_worker) | |
90 | 97 | <div class="chatbox__toper-info messages__item-info"> |
91 | 98 | <div class="messages__item-photo"> |
92 | 99 | <svg> |
... | ... | @@ -151,51 +158,52 @@ |
151 | 158 | @endif |
152 | 159 | |
153 | 160 | <div class="chatbox__list" id="dialogs" name="dialogs"> |
154 | - @if ($Messages->count()) | |
161 | + @if ($Messages->count()) | |
155 | 162 | @foreach ($Messages as $it) |
156 | 163 | @if ($it->user_id == $companion->id) |
157 | 164 | <div class="chatbox__item"> |
158 | - <div class="chatbox__item-photo"> | |
159 | - <svg> | |
160 | - <use xlink:href="{{ asset('images/sprite.svg#pic') }}"></use> | |
161 | - </svg> | |
162 | - | |
163 | - @if ($companion->is_worker) | |
165 | + <div class="@if(!$companion->id != $superAdmin->id) chatbox__item-photo @endif "> | |
166 | + @if(!$companion->id == $superAdmin->id) | |
167 | + <svg> | |
168 | + <use xlink:href="{{ asset('images/sprite.svg#pic') }}"></use> | |
169 | + </svg> | |
170 | + @endif | |
171 | + @if($companion->is_worker) | |
164 | 172 | @if ((isset($companion->workers[0]->photo)) && |
165 | 173 | (!empty($companion->workers[0]->photo))) |
166 | 174 | <img src="{{ asset(\Illuminate\Support\Facades\Storage::url($companion->workers[0]->photo)) }}" alt=""> |
167 | 175 | @else |
168 | 176 | <img src="{{ asset('images/default_man.jpg') }}" alt=""> |
169 | 177 | @endif |
178 | + @elseif($companion->id == $superAdmin->id) | |
179 | + @include('svg.logo_icon') | |
170 | 180 | @else |
171 | 181 | @if ((isset($companion->employers[0]->logo)) && |
172 | 182 | (!empty($companion->employers[0]->logo))) |
173 | 183 | <img src="{{ asset(\Illuminate\Support\Facades\Storage::url($companion->employers[0]->logo)) }}" alt=""> |
174 | 184 | @else |
175 | - <img src="{{ asset('images/default_man.jpg') }}" alt=""> | |
185 | + <div class="chatbox__item-photo "> | |
186 | + | |
187 | + <img src="{{ asset('images/default_man.jpg') }}" alt=""> | |
188 | + </div> | |
189 | + | |
176 | 190 | @endif |
177 | 191 | @endif |
178 | 192 | </div> |
179 | 193 | <div class="chatbox__item-body"> |
180 | - @if($it->text || $it->reply_message_id || $it->ad_employer_id > 0) | |
194 | + @if(\App\Models\Ad_employer::where('id', $it->ad_employer_id)->exists()) | |
181 | 195 | <div class="chatbox__item-text"> |
182 | - @if($it->ad_employer_id > 0) | |
183 | - <b>Отклик на вакансию</b> "{{ \App\Models\Ad_employer::find($it->ad_employer_id)?->name }}"<br> | |
184 | - @if($it->text) | |
185 | - <b>Комментарий:</b> {{ $it->text }} | |
186 | - @endif | |
187 | - @else | |
188 | - @if($it->text) | |
189 | - {{ $it->text }} | |
190 | - @endif | |
191 | - @endif | |
192 | - | |
193 | - @if($it->reply_message_id) | |
194 | - <div class="reply-message"> | |
195 | - {{ $it->reply_message->text }} | |
196 | - </div> | |
196 | + Отклик на вакансию {{ \App\Models\Ad_employer::find($it->ad_employer_id)->name }} | |
197 | + @if($it->text) | |
198 | + Комментарий: {{ $it->text }} | |
197 | 199 | @endif |
198 | 200 | </div> |
201 | + @else | |
202 | + @if($it->text) | |
203 | + <div class="chatbox__item-text"> | |
204 | + {{ $it->text }} | |
205 | + </div> | |
206 | + @endif | |
199 | 207 | @endif |
200 | 208 | @if ((isset($it->file)) && (!empty($it->file))) |
201 | 209 | <div class="chatbox__item-text chatbox__item-body-file-name-wrap"> |
... | ... | @@ -218,11 +226,7 @@ |
218 | 226 | </div> |
219 | 227 | @else |
220 | 228 | <div class="chatbox__item chatbox__item_reverse"> |
221 | - <div class="chatbox__item-photo"> | |
222 | - <svg> | |
223 | - <use xlink:href="{{ asset('images/sprite.svg#pic') }}"></use> | |
224 | - </svg> | |
225 | - | |
229 | + <div class="@if($sender->id!=$superAdmin->id) chatbox__item-photo @endif"> | |
226 | 230 | @if ($sender->is_worker) |
227 | 231 | @if ((isset($sender->workers[0]->photo)) && |
228 | 232 | (!empty($sender->workers[0]->photo))) |
... | ... | @@ -230,7 +234,13 @@ |
230 | 234 | @else |
231 | 235 | <img src="{{ asset('images/default_man.jpg') }}" alt=""> |
232 | 236 | @endif |
237 | + @elseif($sender->id == $superAdmin->id) | |
238 | + @include('svg.logo_icon') | |
233 | 239 | @else |
240 | + <svg> | |
241 | + <use xlink:href="{{ asset('images/sprite.svg#pic') }}"></use> | |
242 | + </svg> | |
243 | + | |
234 | 244 | @if ((isset($sender->employers[0]->logo)) && |
235 | 245 | (!empty($sender->employers[0]->logo))) |
236 | 246 | <img src="{{ asset(\Illuminate\Support\Facades\Storage::url($sender->employers[0]->logo)) }}" alt=""> |
... | ... | @@ -238,21 +248,36 @@ |
238 | 248 | <img src="{{ asset('images/default_man.jpg') }}" alt=""> |
239 | 249 | @endif |
240 | 250 | @endif |
241 | - | |
242 | 251 | </div> |
243 | 252 | <div class="chatbox__item-body"> |
244 | - @if($it->text) | |
253 | + @if($chat->is_admin_chat || $it->text || $it->reply_message_id || $it->ad_employer_id > 0) | |
245 | 254 | <div class="chatbox__item-text"> |
246 | - @if(\App\Models\Ad_employer::where('id', $it->ad_employer_id)->exists()) | |
247 | - <b>Отклик на вакансию</b> "{{ \App\Models\Ad_employer::find($it->ad_employer_id)->name }}"<br> | |
248 | - @if($it->text) | |
249 | - <b>Комментарий:</b> {{ $it->text }} | |
250 | - @endif | |
255 | + | |
256 | + @if($chat->is_admin_chat) | |
257 | + <button class="button admin-chat-answer" data-fancybox data-src="#answer_from_admin_chat_modal" | |
258 | + data-to-user-id="{{ $it->user_id }}" data-message-id="{{ $it->id }}" | |
259 | + > | |
260 | + Ответить | |
261 | + </button> | |
262 | + @endif | |
263 | + | |
264 | + @if(\App\Models\Ad_employer::where('id', $it->ad_employer_id)->exists())) | |
265 | + <b>Отклик на вакансию</b> "{{ \App\Models\Ad_employer::find($it->ad_employer_id)->name }}"<br> | |
266 | + @if($it->text) | |
267 | + <b>Комментарий:</b> {{ $it->text }} | |
268 | + @endif | |
251 | 269 | @else |
252 | 270 | @if($it->text) |
253 | 271 | {{ $it->text }} |
254 | 272 | @endif |
255 | - @endif</div> | |
273 | + @endif | |
274 | + | |
275 | + @if($it->reply_message_id) | |
276 | + <div class="reply-message"> | |
277 | + {{ $it->reply_message->text }} | |
278 | + </div> | |
279 | + @endif | |
280 | + </div> | |
256 | 281 | @endif |
257 | 282 | @if ((isset($it->file)) && (!empty($it->file))) |
258 | 283 | <div class="chatbox__item-text chatbox__item-body-file-name-wrap"> |
resources/views/employers/subcribe.blade.php
... | ... | @@ -27,12 +27,15 @@ |
27 | 27 | </div> |
28 | 28 | @include('messages_error') |
29 | 29 | <div class="cabinet__body-item"> |
30 | - <form class="cabinet__nots" action="{{ route('employer.save_subscribe') }}"> | |
30 | + <form class="cabinet__nots" action="{{ route('employer.save_subscribe') }}" method="post"> | |
31 | 31 | @csrf |
32 | 32 | <p class="cabinet__text">Укажите адрес электронной почты для получения уведомлений</p> |
33 | - <input type="email" name="email" class="input" placeholder="info@rekamore.su" required> | |
33 | + <input type="email" name="email" class="input" placeholder="info@rekamore.su" required | |
34 | + value="{{$user->subscribe_email??$user->subscribe_email}}" | |
35 | + > | |
34 | 36 | <label class="checkbox"> |
35 | - <input type="checkbox" name="email_msg" class="checkbox__input"> | |
37 | + <input type="checkbox" name="email_msg" class="checkbox__input" | |
38 | + {{ $user->subscribe == 1 ? 'checked' : '' }}> | |
36 | 39 | <span class="checkbox__icon"> |
37 | 40 | <svg> |
38 | 41 | <use xlink:href="{{ asset('images/sprite.svg#v') }}"></use> |
resources/views/list_vacancies.blade.php
... | ... | @@ -175,7 +175,7 @@ |
175 | 175 | @if (!empty($Q->employer->logo)) |
176 | 176 | <img src="{{ asset(Storage::url($Q->employer->logo)) }}" alt="{{ $Q->employer->name }}"> |
177 | 177 | @else |
178 | - <img src="{{ asset('images/default_ship.jpg') }}" alt="{{ $Rec->title }}" class="main__vacancies-thing-pic"> | |
178 | + <img src="{{ asset('images/default_ship.jpg') }}" alt="{{ $Q->title }}" class="main__vacancies-thing-pic"> | |
179 | 179 | @endif |
180 | 180 | <span>@if (isset($Q->employer->name_company)) {{ $Q->employer->name_company }} @else Не определена @endif</span> |
181 | 181 | </div> |
... | ... | @@ -213,7 +213,7 @@ |
213 | 213 | @else |
214 | 214 | @if (App\Classes\StatusUser::Status() == 1) |
215 | 215 | <?php |
216 | - if (\App\Classes\Tools::getWorkerProfilePercent(Auth()->user()->workers[0]) >= 50) { | |
216 | + if (\App\Classes\Tools::getWorkerProfilePercent(Auth()->user()->workers[0]) >= 10) { | |
217 | 217 | $buttonId = 'ask_comment'; |
218 | 218 | } else { |
219 | 219 | $buttonId = 'ask_percent'; |
resources/views/workers/dialog.blade.php
... | ... | @@ -166,10 +166,12 @@ |
166 | 166 | @foreach ($Messages as $it) |
167 | 167 | @if ($it->user_id == $companion->id) |
168 | 168 | <div class="chatbox__item"> |
169 | - <div class="chatbox__item-photo"> | |
169 | + <div class="@if(!$companion->id == $supeAdmin->id) chatbox__item-photo @endif"> | |
170 | + @if(!$companion->id == $supeAdmin->id) | |
170 | 171 | <svg> |
171 | 172 | <use xlink:href="{{ asset('images/sprite.svg#pic') }}"></use> |
172 | 173 | </svg> |
174 | + @endif | |
173 | 175 | @if($companion->is_worker) |
174 | 176 | @if ((isset($companion->workers[0]->photo)) && |
175 | 177 | (!empty($companion->workers[0]->photo))) |
... | ... | @@ -177,12 +179,18 @@ |
177 | 179 | @else |
178 | 180 | <img src="{{ asset('images/default_man.jpg') }}" alt=""> |
179 | 181 | @endif |
182 | + @elseif($companion->id == $supeAdmin->id) | |
183 | + @include('svg.logo_icon') | |
180 | 184 | @else |
181 | 185 | @if ((isset($companion->employers[0]->logo)) && |
182 | 186 | (!empty($companion->employers[0]->logo))) |
183 | 187 | <img src="{{ asset(\Illuminate\Support\Facades\Storage::url($companion->employers[0]->logo)) }}" alt=""> |
184 | 188 | @else |
189 | + <div class="chatbox__item-photo "> | |
190 | + | |
185 | 191 | <img src="{{ asset('images/default_man.jpg') }}" alt=""> |
192 | + </div> | |
193 | + | |
186 | 194 | @endif |
187 | 195 | @endif |
188 | 196 | </div> |
... | ... | @@ -196,7 +204,9 @@ |
196 | 204 | </div> |
197 | 205 | @else |
198 | 206 | @if($it->text) |
207 | + <div class="chatbox__item-text"> | |
199 | 208 | {{ $it->text }} |
209 | + </div> | |
200 | 210 | @endif |
201 | 211 | @endif |
202 | 212 | @if ((isset($it->file)) && (!empty($it->file))) |
... | ... | @@ -220,10 +230,8 @@ |
220 | 230 | </div> |
221 | 231 | @else |
222 | 232 | <div class="chatbox__item chatbox__item_reverse"> |
223 | - <div class="@if(!$chat->is_admin_chat) chatbox__item-photo @endif"> | |
224 | - @if($chat->is_admin_chat) | |
233 | + <div class="chatbox__item-photo "> | |
225 | 234 | @include('svg.logo_icon') |
226 | - @else | |
227 | 235 | @if ($sender->is_worker) |
228 | 236 | @if ((isset($sender->workers[0]->photo)) && |
229 | 237 | (!empty($sender->workers[0]->photo))) |
... | ... | @@ -231,6 +239,10 @@ |
231 | 239 | @else |
232 | 240 | <img src="{{ asset('images/default_man.jpg') }}" alt=""> |
233 | 241 | @endif |
242 | + @elseif($sender->id == $supeAdmin->id) | |
243 | + | |
244 | + @include('svg.logo_icon') | |
245 | + | |
234 | 246 | @else |
235 | 247 | <svg> |
236 | 248 | <use xlink:href="{{ asset('images/sprite.svg#pic') }}"></use> |
... | ... | @@ -243,18 +255,18 @@ |
243 | 255 | <img src="{{ asset('images/default_man.jpg') }}" alt=""> |
244 | 256 | @endif |
245 | 257 | @endif |
246 | - @endif | |
247 | 258 | </div> |
248 | 259 | <div class="chatbox__item-body"> |
249 | 260 | @if($chat->is_admin_chat || $it->text || $it->reply_message_id || $it->ad_employer_id > 0) |
250 | 261 | <div class="chatbox__item-text"> |
251 | - @if($chat->is_admin_chat) | |
252 | - <button class="button admin-chat-answer" data-fancybox data-src="#answer_from_admin_chat_modal" | |
253 | - data-to-user-id="{{ $it->user_id }}" data-message-id="{{ $it->id }}" | |
254 | - > | |
255 | - Ответить | |
256 | - </button> | |
257 | - @endif | |
262 | + | |
263 | +{{-- @if($chat->is_admin_chat)--}} | |
264 | +{{-- <button class="button admin-chat-answer" data-fancybox data-src="#answer_from_admin_chat_modal"--}} | |
265 | +{{-- data-to-user-id="{{ $it->user_id }}" data-message-id="{{ $it->id }}"--}} | |
266 | +{{-- >--}} | |
267 | +{{-- Ответить--}} | |
268 | +{{-- </button>--}} | |
269 | +{{-- @endif--}} | |
258 | 270 | |
259 | 271 | @if(\App\Models\Ad_employer::where('id', $it->ad_employer_id)->exists())) |
260 | 272 | <b>Отклик на вакансию</b> "{{ \App\Models\Ad_employer::find($it->ad_employer_id)->name }}"<br> |
... | ... | @@ -298,7 +310,7 @@ |
298 | 310 | @endforeach |
299 | 311 | @endif |
300 | 312 | </div> |
301 | - @if(!$chat->is_admin_chat) | |
313 | + | |
302 | 314 | <div> |
303 | 315 | <form action="{{ route('worker.test123') }}" class="chatbox__bottom" enctype="multipart/form-data" method="POST" > |
304 | 316 | @csrf |
... | ... | @@ -322,7 +334,6 @@ |
322 | 334 | </form> |
323 | 335 | <div class="chatbox-file-name-wrap mt-5 fw600"></div> |
324 | 336 | </div> |
325 | - @endif | |
326 | 337 | </div> |
327 | 338 | </div> |
328 | 339 | </div> |
resources/views/workers/menu.blade.php
... | ... | @@ -50,6 +50,13 @@ |
50 | 50 | </i> |
51 | 51 | <span>Избранные вакансии</span> |
52 | 52 | </a> |
53 | + | |
54 | + <a href="{{ route('worker.subscribe') }}" class="cabinet__menu-item @if ($item==11) active @endif"> | |
55 | + <i><svg> | |
56 | + <use xlink:href="{{ asset('images/sprite.svg#cabinet-11') }}"></use> | |
57 | + </svg></i> | |
58 | + <span>Настройки уведомлений</span> | |
59 | + </a> | |
53 | 60 | <a href="{{ route('worker.new_password') }}" class="cabinet__menu-item green @if ($item==4) active @endif"> |
54 | 61 | <i></i> |
55 | 62 | <span>Сменить пароль</span> |
resources/views/workers/subcribe.blade.php
... | ... | @@ -0,0 +1,51 @@ |
1 | +@extends('layout.frontend', ['title' => 'Настройка уведомлений - РекаМоре']) | |
2 | + | |
3 | +@section('scripts') | |
4 | + | |
5 | +@endsection | |
6 | + | |
7 | +@section('content') | |
8 | + <section class="cabinet"> | |
9 | + <div class="container"> | |
10 | + <ul class="breadcrumbs cabinet__breadcrumbs"> | |
11 | + <li><a href="{{ route('index') }}">Главная</a></li> | |
12 | + <li><b>Личный кабинет</b></li> | |
13 | + </ul> | |
14 | + <div class="cabinet__wrapper"> | |
15 | + <div class="cabinet__side"> | |
16 | + @include('workers.menu', ['item' => 11]) | |
17 | + </div> | |
18 | + | |
19 | + <div class="cabinet__body"> | |
20 | + <div class="cabinet__body-item"> | |
21 | + <h2 class="title cabinet__title">Настройки уведомлений</h2> | |
22 | + </div> | |
23 | + @include('messages_error') | |
24 | + <div class="cabinet__body-item"> | |
25 | + <form class="cabinet__nots" action="{{ route('worker.save_subscribe') }}" method="post"> | |
26 | + @csrf | |
27 | + <p class="cabinet__text">Укажите адрес электронной почты для получения уведомлений</p> | |
28 | + <input type="email" name="email" class="input" placeholder="info@rekamore.su" required | |
29 | + value="{{$user->subscribe_email??$user->subscribe_email}}" | |
30 | + > | |
31 | + <label class="checkbox"> | |
32 | + <input type="checkbox" name="email_msg" class="checkbox__input" | |
33 | + {{ $user->subscribe == 1 ? 'checked' : '' }}> | |
34 | + <span class="checkbox__icon"> | |
35 | + <svg> | |
36 | + <use xlink:href="{{ asset('images/sprite.svg#v') }}"></use> | |
37 | + </svg> | |
38 | + </span> | |
39 | + <span class="checkbox__text"> | |
40 | + <span>Получать уведомления о новых сообщениях на почту</span> | |
41 | + </span> | |
42 | + </label> | |
43 | + <button type="submit" class="button">Сохранить</button> | |
44 | + </form> | |
45 | + </div> | |
46 | + </div> | |
47 | + </div> | |
48 | + </div> | |
49 | + </section> | |
50 | + </div> | |
51 | +@endsection |
routes/web.php
... | ... | @@ -473,6 +473,9 @@ Route::group([ |
473 | 473 | Route::post('cabinet/{worker}', [WorkerController::class, 'cabinet_save'])->name('cabinet_save'); |
474 | 474 | Route::post('cabinet/cabinet_save_foto/{worker}', [WorkerController::class, 'cabinet_save_foto'])->name('cabinet_save_foto'); |
475 | 475 | |
476 | + Route::get('cabinet/subscribe', [WorkerController::class, 'subscribe'])->name('subscribe'); | |
477 | + Route::post('cabinet/subscribe/save', [WorkerController::class, 'save_subscribe'])->name('save_subscribe'); | |
478 | + | |
476 | 479 | |
477 | 480 | // 2 страница - Сообщения |
478 | 481 | Route::get('cabinet/messages/{type_message}', [WorkerController::class, 'messages'])->name('messages'); |
... | ... | @@ -536,6 +539,7 @@ Route::group([ |
536 | 539 | Route::get('cabinet/autolift', [WorkerController::class, 'resumeAutoLiftForm'])->name('autolift'); |
537 | 540 | Route::post('cabinet/autolift/save', [WorkerController::class, 'resumeAutoLiftSave'])->name('autolift_save'); |
538 | 541 | }); |
542 | +Route::post('/admin/chat/response', [WorkerController::class, 'adminChatResponse'])->name('admin.chat.response'); | |
539 | 543 | |
540 | 544 | // Личный кабинет работодателя |
541 | 545 | Route::group([ |
... | ... | @@ -621,7 +625,7 @@ Route::group([ |
621 | 625 | |
622 | 626 | // 11 страница - Настройка уведомлений |
623 | 627 | Route::get('cabinet/subscribe', [EmployerController::class, 'subscribe'])->name('subscribe'); |
624 | - Route::get('cabinet/subscribe/save', [EmployerController::class, 'save_subscribe'])->name('save_subscribe'); | |
628 | + Route::post('cabinet/subscribe/save', [EmployerController::class, 'save_subscribe'])->name('save_subscribe'); | |
625 | 629 | |
626 | 630 | // 12 страница - Сменить пароль |
627 | 631 | Route::get('cabinet/password-reset', [EmployerController::class, 'password_reset'])->name('password_reset'); |