Commit 356dd9836ee3cac31ea1b8b5da387b62f8e9b50c
Exists in
master
uncommited files
Showing 21 changed files Side-by-side Diff
- app/Http/Controllers/EmployerController.php
- app/Http/Controllers/WorkerController.php
- app/Models/Chat.php
- app/Models/Message.php
- database/migrations/2024_07_19_063615_create_chat_table.php
- public/css/helpers.css
- public/css/style_may2024.css
- public/images/pin_off.svg
- public/images/pin_on.svg
- public/images/sprite.svg
- public/js/func.js
- resources/views/chats/chats_list.blade.php
- resources/views/employers/dialog.blade.php
- resources/views/employers/messages.blade.php
- resources/views/layout/frontend.blade.php
- resources/views/modals/chats/remove_chat.blade.php
- resources/views/svg/pin_off.blade.php
- resources/views/svg/pin_on.blade.php
- resources/views/workers/dialog.blade.php
- resources/views/workers/messages.blade.php
- routes/web.php
app/Http/Controllers/EmployerController.php
... | ... | @@ -14,6 +14,7 @@ use App\Mail\SendAllMessages; |
14 | 14 | use App\Models\Ad_employer; |
15 | 15 | use App\Models\ad_response; |
16 | 16 | use App\Models\Category; |
17 | +use App\Models\Chat; | |
17 | 18 | use App\Models\Employer; |
18 | 19 | use App\Models\Flot; |
19 | 20 | use App\Models\Job_title; |
... | ... | @@ -337,28 +338,10 @@ class EmployerController extends Controller |
337 | 338 | public function messages($type_message) { |
338 | 339 | $user_id = Auth()->user()->id; |
339 | 340 | |
340 | - $messages_input = Message::query()->with('vacancies')->with('user_from')-> | |
341 | - Where('to_user_id', $user_id)->OrderByDesc('created_at'); | |
341 | + $chats = Chat::get_user_chats($user_id); | |
342 | + $user_type = 'employer'; | |
342 | 343 | |
343 | - $messages_output = Message::query()->with('vacancies')-> | |
344 | - with('user_to')->where('user_id', $user_id)-> | |
345 | - OrderByDesc('created_at'); | |
346 | - | |
347 | - $count_input = $messages_input->count(); | |
348 | - $count_output = $messages_output->count(); | |
349 | - | |
350 | - if ($type_message == 'input') { | |
351 | - $messages = $messages_input->paginate(5); | |
352 | - } | |
353 | - | |
354 | - if ($type_message == 'output') { | |
355 | - $messages = $messages_output->paginate(5); | |
356 | - } | |
357 | - | |
358 | - //dd($user_id, $messages[2]->vacancies); | |
359 | - //jobs); | |
360 | - | |
361 | - return view('employers.messages', compact('messages', 'count_input', 'count_output', 'type_message', 'user_id')); | |
344 | + return view('employers.messages', compact('chats','user_id', 'user_type')); | |
362 | 345 | } |
363 | 346 | |
364 | 347 | // Диалог между пользователями |
... | ... | @@ -376,23 +359,39 @@ class EmployerController extends Controller |
376 | 359 | where('id', $user2->id)->first(); |
377 | 360 | } |
378 | 361 | |
379 | - $Messages = Message::query()-> | |
380 | - where('ad_employer_id', '=', $ad_employer)-> | |
381 | - where(function($query) use ($user1, $user2) { | |
382 | - $query->where('user_id', $user1->id)->where('to_user_id', $user2->id); | |
383 | - })->orWhere(function($query) use ($user1, $user2) { | |
384 | - $query->where('user_id', $user2->id)->where('to_user_id', $user1->id); | |
385 | - })->where('ad_employer_id', '=', $ad_employer)->OrderBy('created_at')->get(); | |
386 | - | |
387 | - $id_vac = $Messages[$Messages->count() - 1]->ad_employer_id; | |
362 | + $Messages = Message::query() | |
363 | + ->where(function($query) use ($user1, $user2) { | |
364 | + $query->where('user_id', $user1->id)->where('to_user_id', $user2->id); | |
365 | + }) | |
366 | + ->orWhere(function($query) use ($user1, $user2) { | |
367 | + $query->where('user_id', $user2->id)->where('to_user_id', $user1->id); | |
368 | + }) | |
369 | + ->orderBy('created_at') | |
370 | + ->get() | |
371 | + ; | |
388 | 372 | |
389 | - //$ad_employer = null; | |
390 | - //if (!is_null($id_vac)) $ad_employer = Ad_employer::query()->where('id', $id_vac)->first(); | |
391 | 373 | $sender = $user1; |
392 | 374 | |
375 | + Message::where('user_id', '=', $user2->id) | |
376 | + ->where('to_user_id', '=', $user1->id) | |
377 | + ->update(['flag_new' => 0]) | |
378 | + ; | |
379 | + | |
393 | 380 | return view('employers.dialog', compact('companion', 'sender', 'ad_employer', 'Messages')); |
394 | 381 | } |
395 | 382 | |
383 | + public function pin_chat(Request $request){ | |
384 | + $chat_id = $request->get('id'); | |
385 | + $is_fixed = $request->get('is_fixed'); | |
386 | + | |
387 | + Chat::pin_chat($chat_id, $is_fixed); | |
388 | + } | |
389 | + | |
390 | + public function remove_chat(Request $request){ | |
391 | + $chat_id = $request->get('id'); | |
392 | + Chat::remove_chat($chat_id); | |
393 | + } | |
394 | + | |
396 | 395 | // Регистрация работодателя |
397 | 396 | public function register_employer(Request $request) { |
398 | 397 | $params = $request->all(); |
... | ... | @@ -535,10 +534,8 @@ class EmployerController extends Controller |
535 | 534 | return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]) |
536 | 535 | ->withErrors($validator); |
537 | 536 | } else { |
538 | - if ($request->has('file')) { | |
539 | - $params['file'] = $request->file('file')->store("messages", 'public'); | |
540 | - } | |
541 | - Message::create($params); | |
537 | + Message::add_message($request, $user1, $user2, $request->all(), file_store_path: 'messages'); | |
538 | + | |
542 | 539 | //return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]); |
543 | 540 | return redirect()->route('employer.dialog', |
544 | 541 | ['user1' => $user1, 'user2' => $user2, 'ad_employer' => $id_vacancy, 'ad_name' => $ad_name]); |
... | ... | @@ -756,25 +753,23 @@ class EmployerController extends Controller |
756 | 753 | ////////////////////////////////////////////////////////////////// |
757 | 754 | public function new_message(Request $request) { |
758 | 755 | $params = $request->all(); |
756 | + | |
759 | 757 | $id = $params['_user_id']; |
760 | - $message = new Message(); | |
761 | - $message->user_id = $params['_user_id']; | |
762 | - $message->to_user_id = $params['_to_user_id']; | |
763 | - $message->title = $params['title']; | |
764 | - $message->text = $params['text']; | |
765 | - if ($request->has('_file')) { | |
766 | - $message->file = $request->file('_file')->store("worker/$id", 'public'); | |
767 | - } | |
768 | - $message->ad_employer_id = $params['_vacancy']; | |
769 | - $message->flag_new = 1; | |
770 | - $id_message = $message->save(); | |
758 | + $message_params = [ | |
759 | + 'title' => $params['title'], | |
760 | + 'text' => $params['text'], | |
761 | + 'ad_employer_id' => $params['_vacancy'], | |
762 | + 'flag_new' => 1 | |
763 | + ]; | |
771 | 764 | |
772 | - //$data['message_id'] = $id_message; | |
773 | - //$data['ad_employer_id'] = $params['_vacancy']; | |
774 | - //$data['job_title_id'] = 0; | |
765 | + Message::add_message( | |
766 | + $request, | |
767 | + $params['_user_id'], | |
768 | + $params['_to_user_id'], | |
769 | + $message_params, | |
770 | + file_store_path: "worker/$id" | |
771 | + ); | |
775 | 772 | |
776 | - $data['flag'] = 1; | |
777 | - //$ad_responce = ad_response::create($data); | |
778 | 773 | return redirect()->route('employer.messages', ['type_message' => 'output']); |
779 | 774 | } |
780 | 775 |
app/Http/Controllers/WorkerController.php
... | ... | @@ -8,6 +8,7 @@ use App\Http\Requests\PrevCompanyRequest; |
8 | 8 | use App\Http\Requests\SertificationRequest; |
9 | 9 | use App\Models\Ad_employer; |
10 | 10 | use App\Models\ad_response; |
11 | +use App\Models\Chat; | |
11 | 12 | use App\Models\Dop_info; |
12 | 13 | use App\Models\infobloks; |
13 | 14 | use App\Models\Job_title; |
... | ... | @@ -494,27 +495,10 @@ class WorkerController extends Controller |
494 | 495 | { |
495 | 496 | $user_id = Auth()->user()->id; |
496 | 497 | |
497 | - $messages_input = Message::query()->with('vacancies')->with('user_from')-> | |
498 | - Where('to_user_id', $user_id)->OrderByDesc('created_at'); | |
498 | + $chats = Chat::get_user_chats($user_id); | |
499 | + $user_type = 'worker'; | |
499 | 500 | |
500 | - $messages_output = Message::query()->with('vacancies')-> | |
501 | - with('user_to')->where('user_id', $user_id)-> | |
502 | - OrderByDesc('created_at'); | |
503 | - | |
504 | - $count_input = $messages_input->count(); | |
505 | - $count_output = $messages_output->count(); | |
506 | - | |
507 | - if ($type_message == 'input') { | |
508 | - $messages = $messages_input->paginate(5); | |
509 | - } | |
510 | - | |
511 | - if ($type_message == 'output') { | |
512 | - $messages = $messages_output->paginate(5); | |
513 | - } | |
514 | - | |
515 | - //dd($messages); | |
516 | - // Вернуть все 100% | |
517 | - return view('workers.messages', compact('messages', 'count_input', 'count_output', 'type_message', 'user_id')); | |
501 | + return view('workers.messages', compact('chats','user_id', 'user_type')); | |
518 | 502 | } |
519 | 503 | |
520 | 504 | // Избранный |
... | ... | @@ -840,28 +824,13 @@ class WorkerController extends Controller |
840 | 824 | } |
841 | 825 | |
842 | 826 | $Messages = Message::query()-> |
843 | - //with('response')-> | |
844 | - where(function($query) use ($user1, $user2) { | |
845 | - $query->where('user_id', $user1->id)->where('to_user_id', $user2->id); | |
846 | - })->orWhere(function($query) use ($user1, $user2) { | |
847 | - $query->where('user_id', $user2->id)->where('to_user_id', $user1->id); | |
848 | - })->OrderBy('created_at')->get(); | |
849 | - | |
850 | - $id_vac = null; | |
851 | - /*foreach ($Messages as $it) { | |
852 | - if (isset($it->response)) { | |
853 | - foreach ($it->response as $r) { | |
854 | - if (isset($r->ad_employer_id)) { | |
855 | - $id_vac = $r->ad_employer_id; | |
856 | - break; | |
857 | - } | |
858 | - } | |
859 | - } | |
860 | - if (!is_null($id_vac)) break; | |
861 | - }*/ | |
862 | - | |
863 | - //$ad_employer = null; | |
864 | - //if (!is_null($id_vac)) $ad_employer = Ad_employer::query()->where('id', $id_vac)->first(); | |
827 | + where(function($query) use ($user1, $user2) { | |
828 | + $query->where('user_id', $user1->id)->where('to_user_id', $user2->id); | |
829 | + })->orWhere(function($query) use ($user1, $user2) { | |
830 | + $query->where('user_id', $user2->id)->where('to_user_id', $user1->id); | |
831 | + })->OrderBy('created_at') | |
832 | + ->get() | |
833 | + ; | |
865 | 834 | |
866 | 835 | return view('workers.dialog', compact('companion', 'sender', 'Messages', 'ad_employer')); |
867 | 836 | } |
... | ... | @@ -1046,17 +1015,20 @@ class WorkerController extends Controller |
1046 | 1015 | $params = $request->all(); |
1047 | 1016 | |
1048 | 1017 | $id = $params['send_user_id']; |
1049 | - $message = new Message(); | |
1050 | - $message->user_id = $params['send_user_id']; | |
1051 | - $message->to_user_id = $params['send_to_user_id']; | |
1052 | - $message->title = $params['send_title']; | |
1053 | - $message->text = $params['send_text']; | |
1054 | - $message->ad_employer_id = $params['send_vacancy']; | |
1055 | - if ($request->has('send_file')) { | |
1056 | - $message->file = $request->file('send_file')->store("worker/$id", 'public'); | |
1057 | - } | |
1058 | - $message->flag_new = 1; | |
1059 | - $id_message = $message->save(); | |
1018 | + $message_params = [ | |
1019 | + 'title' => $params['send_title'], | |
1020 | + 'text' => $params['send_text'], | |
1021 | + 'ad_employer_id' => $params['send_vacancy'], | |
1022 | + 'flag_new' => 1 | |
1023 | + ]; | |
1024 | + | |
1025 | + $id_message = Message::add_message( | |
1026 | + $request, | |
1027 | + $params['send_user_id'], | |
1028 | + $params['send_to_user_id'], | |
1029 | + $message_params, | |
1030 | + file_store_path: "worker/$id" | |
1031 | + ); | |
1060 | 1032 | |
1061 | 1033 | $data['message_id'] = $id_message; |
1062 | 1034 | $data['ad_employer_id'] = $params['send_vacancy']; |
... | ... | @@ -1098,11 +1070,8 @@ class WorkerController extends Controller |
1098 | 1070 | return redirect()->route('worker.dialog', ['user1' => $user1, 'user2' => $user2, 'ad_employer' => $id_vacancy, 'ad_name' => $ad_name]) |
1099 | 1071 | ->withErrors($validator); |
1100 | 1072 | } else { |
1101 | - if ($request->has('file')) { | |
1102 | - $params['file'] = $request->file('file')->store("messages", 'public'); | |
1103 | - } | |
1104 | - Message::create($params); | |
1105 | - //return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]); | |
1073 | + Message::add_message($request, $user1, $user2, $request->all(), file_store_path: 'messages'); | |
1074 | + | |
1106 | 1075 | return redirect()->route('worker.dialog', |
1107 | 1076 | ['user1' => $user1, 'user2' => $user2, 'ad_employer' => $id_vacancy, 'ad_name' => $ad_name]); |
1108 | 1077 |
app/Models/Chat.php
... | ... | @@ -0,0 +1,77 @@ |
1 | +<?php | |
2 | + | |
3 | +namespace App\Models; | |
4 | + | |
5 | +use Illuminate\Database\Eloquent\Factories\HasFactory; | |
6 | +use Illuminate\Database\Eloquent\Model; | |
7 | +use Carbon\Carbon; | |
8 | + | |
9 | +class Chat extends Model | |
10 | +{ | |
11 | + use HasFactory; | |
12 | + | |
13 | + protected $fillable = [ | |
14 | + 'user_id', | |
15 | + 'to_user_id', | |
16 | + 'is_removed', | |
17 | + 'is_fixed', | |
18 | + 'last_message_date', | |
19 | + 'last_message_id', | |
20 | + 'fixed_time' | |
21 | + ]; | |
22 | + | |
23 | + public function user() { | |
24 | + return $this->belongsTo(User::class, 'to_user_id'); | |
25 | + } | |
26 | + | |
27 | + public function worker() { | |
28 | + return $this->belongsTo(Worker::class, 'to_user_id', 'user_id'); | |
29 | + } | |
30 | + | |
31 | + public function employer() { | |
32 | + return $this->belongsTo(Employer::class, 'to_user_id', 'user_id'); | |
33 | + } | |
34 | + | |
35 | + public function last_message() { | |
36 | + return $this->belongsTo(Message::class, 'last_message_id'); | |
37 | + } | |
38 | + | |
39 | + public function unread_messages() | |
40 | + { | |
41 | + return $this->hasMany(Message::class, 'user_id', 'to_user_id'); | |
42 | + } | |
43 | + | |
44 | + public static function pin_chat(int $chat_id, $fixed) | |
45 | + { | |
46 | + return self::where('id', '=', $chat_id) | |
47 | + ->update([ | |
48 | + 'is_fixed' => !empty($fixed) ? 1 : 0, | |
49 | + 'fixation_date' => !empty($fixed) ? Carbon::now() : null | |
50 | + ]); | |
51 | + } | |
52 | + | |
53 | + public static function remove_chat(int $chat_id) | |
54 | + { | |
55 | + return self::where('id', '=', $chat_id) | |
56 | + ->update(['is_removed' => 1]); | |
57 | + } | |
58 | + | |
59 | + public static function get_user_chats(int $user_id){ | |
60 | + return Chat::query() | |
61 | + ->with('user') | |
62 | + ->with('worker') | |
63 | + ->with('employer') | |
64 | + ->with('last_message') | |
65 | + ->withCount(['unread_messages' => function ($query) use($user_id) { | |
66 | + $query->where('to_user_id', '=', $user_id)->where('flag_new', '=', 1); | |
67 | + }]) | |
68 | + ->where('user_id', '=', $user_id) | |
69 | + ->where('is_removed', '=', 0) | |
70 | + ->orderByDesc('is_fixed') | |
71 | + ->orderByDesc('fixation_date') | |
72 | + ->orderByDesc('last_message_date') | |
73 | + ->paginate(5) | |
74 | + ; | |
75 | + } | |
76 | + | |
77 | +} |
app/Models/Message.php
... | ... | @@ -4,6 +4,8 @@ namespace App\Models; |
4 | 4 | |
5 | 5 | use Illuminate\Database\Eloquent\Factories\HasFactory; |
6 | 6 | use Illuminate\Database\Eloquent\Model; |
7 | +use Illuminate\Http\Request; | |
8 | +use Illuminate\Support\Facades\Validator; | |
7 | 9 | |
8 | 10 | class Message extends Model |
9 | 11 | { |
... | ... | @@ -12,6 +14,7 @@ class Message extends Model |
12 | 14 | protected $fillable = [ |
13 | 15 | 'user_id', |
14 | 16 | 'to_user_id', |
17 | + 'title', | |
15 | 18 | 'text', |
16 | 19 | 'file', |
17 | 20 | 'flag_new', |
... | ... | @@ -38,4 +41,36 @@ class Message extends Model |
38 | 41 | public function vacancies() { |
39 | 42 | return $this->belongsTo(Ad_employer::class, 'ad_employer_id', 'id'); |
40 | 43 | } |
44 | + | |
45 | + public static function add_message( | |
46 | + Request $request, | |
47 | + int $user_id, | |
48 | + int $to_user_id, | |
49 | + array $message_params, | |
50 | + string $file_store_path = '/' | |
51 | + ) { | |
52 | + $message_params['user_id'] = $user_id; | |
53 | + $message_params['to_user_id'] = $to_user_id; | |
54 | + if ($request->has('file')) { | |
55 | + $message_params['file'] = $request->file('file')->store($file_store_path, 'public'); | |
56 | + } | |
57 | + | |
58 | + $new_message = Message::create($message_params); | |
59 | + | |
60 | + if (!empty($new_message->id)) { | |
61 | + Chat::updateOrCreate( | |
62 | + ['user_id' => $user_id, 'to_user_id' => $to_user_id], | |
63 | + ['user_id' => $user_id, 'to_user_id' => $to_user_id, 'last_message_date' => date("Y-m-d H:i:s"), 'last_message_id' => $new_message->id] | |
64 | + ); | |
65 | + | |
66 | + Chat::updateOrCreate( | |
67 | + ['user_id' => $to_user_id, 'to_user_id' => $user_id], | |
68 | + ['user_id' => $to_user_id, 'to_user_id' => $user_id, 'last_message_date' => date("Y-m-d H:i:s"), 'last_message_id' => $new_message->id] | |
69 | + ); | |
70 | + } | |
71 | + | |
72 | + return $new_message->id ?? 0; | |
73 | + | |
74 | + } | |
75 | + | |
41 | 76 | } |
database/migrations/2024_07_19_063615_create_chat_table.php
... | ... | @@ -0,0 +1,39 @@ |
1 | +<?php | |
2 | + | |
3 | +use Illuminate\Database\Migrations\Migration; | |
4 | +use Illuminate\Database\Schema\Blueprint; | |
5 | +use Illuminate\Support\Facades\Schema; | |
6 | + | |
7 | +return new class extends Migration | |
8 | +{ | |
9 | + /** | |
10 | + * Run the migrations. | |
11 | + * | |
12 | + * @return void | |
13 | + */ | |
14 | + public function up() | |
15 | + { | |
16 | + Schema::create('chats', function (Blueprint $table) { | |
17 | + $table->id(); | |
18 | + $table->integer('user_id')->nullable(false); | |
19 | + $table->integer('to_user_id'); | |
20 | + $table->boolean('is_removed')->default(false); | |
21 | + $table->boolean('is_fixed')->default(false); | |
22 | + $table->dateTime('fixation_date')->nullable(true); | |
23 | + $table->dateTime('last_message_date')->nullable(false); | |
24 | + $table->integer('last_message_id')->nullable(false); | |
25 | + $table->dateTime('fixed_time')->nullable(true); | |
26 | + $table->timestamps(); | |
27 | + }); | |
28 | + } | |
29 | + | |
30 | + /** | |
31 | + * Reverse the migrations. | |
32 | + * | |
33 | + * @return void | |
34 | + */ | |
35 | + public function down() | |
36 | + { | |
37 | + Schema::dropIfExists('chats'); | |
38 | + } | |
39 | +}; |
public/css/helpers.css
... | ... | @@ -896,4 +896,10 @@ |
896 | 896 | border: 0; |
897 | 897 | } |
898 | 898 | |
899 | +.hover-shadow:hover{ | |
900 | + -webkit-box-shadow: 0px 0px 8px 1px rgba(66, 68, 90, 1); | |
901 | + -moz-box-shadow: 0px 0px 8px 1px rgba(66, 68, 90, 1); | |
902 | + box-shadow: 0px 0px 8px 1px rgba(66, 68, 90, 1); | |
903 | +} | |
904 | + | |
899 | 905 | /*# sourceMappingURL=helpers.css.map */ |
public/css/style_may2024.css
... | ... | @@ -6748,23 +6748,12 @@ main + .news { |
6748 | 6748 | gap: 20px; |
6749 | 6749 | } |
6750 | 6750 | .messages__body { |
6751 | - display: -webkit-box; | |
6752 | - display: -ms-flexbox; | |
6753 | - display: flex; | |
6754 | - -webkit-box-orient: vertical; | |
6755 | - -webkit-box-direction: normal; | |
6756 | - -ms-flex-direction: column; | |
6757 | - flex-direction: column; | |
6758 | - gap: 10px; | |
6759 | - width: 100%; | |
6760 | -} | |
6761 | -@media (min-width: 768px) { | |
6762 | - .messages__body { | |
6763 | - gap: 20px; | |
6764 | - } | |
6751 | + width: 100%; | |
6752 | + max-height: 800px; | |
6753 | + overflow: auto; | |
6754 | + padding: 5px; | |
6765 | 6755 | } |
6766 | 6756 | .messages__item { |
6767 | - display: none; | |
6768 | 6757 | -webkit-box-align: center; |
6769 | 6758 | -ms-flex-align: center; |
6770 | 6759 | align-items: center; |
... | ... | @@ -6773,18 +6762,16 @@ main + .news { |
6773 | 6762 | background: linear-gradient(95deg, #f2f5fc 59.82%, #ebf2fc 99.99%); |
6774 | 6763 | padding: 10px; |
6775 | 6764 | font-size: 12px; |
6765 | + display: flex; | |
6766 | + justify-content: space-between; | |
6767 | + margin-bottom: 20px; | |
6776 | 6768 | } |
6777 | 6769 | @media (min-width: 768px) { |
6778 | 6770 | .messages__item { |
6779 | 6771 | padding: 20px; |
6780 | - font-size: 16px; | |
6772 | + font-size: 18px; | |
6781 | 6773 | } |
6782 | 6774 | } |
6783 | -.messages__item:nth-of-type(1), .messages__item:nth-of-type(2), .messages__item:nth-of-type(3), .messages__item:nth-of-type(4), .messages__item:nth-of-type(5), .messages__item:nth-of-type(6) { | |
6784 | - display: -webkit-box; | |
6785 | - display: -ms-flexbox; | |
6786 | - display: flex; | |
6787 | -} | |
6788 | 6775 | .messages__item-info { |
6789 | 6776 | display: -webkit-box; |
6790 | 6777 | display: -ms-flexbox; |
... | ... | @@ -6860,16 +6847,47 @@ main + .news { |
6860 | 6847 | .messages__item-text span { |
6861 | 6848 | color: #000; |
6862 | 6849 | } |
6863 | -.messages__item-date { | |
6864 | - color: #000; | |
6865 | - width: 90px; | |
6866 | - text-align: right; | |
6850 | +.messages__item-actions{ | |
6851 | + | |
6867 | 6852 | } |
6868 | -@media (min-width: 768px) { | |
6869 | - .messages__item-date { | |
6870 | - width: 150px; | |
6871 | - } | |
6853 | +.messages__item-buttons{ | |
6854 | + float: right; | |
6855 | + display: flex; | |
6856 | + align-items: center; | |
6857 | +} | |
6858 | +.messages__item-buttons button{ | |
6859 | + padding: 0; | |
6860 | + background: unset; | |
6861 | + border: unset; | |
6862 | +} | |
6863 | +.messages__item-buttons button svg{ | |
6864 | + width: 25px; | |
6865 | + height: 25px; | |
6866 | + color: gray; | |
6867 | +} | |
6868 | +.messages__item-buttons button svg path{ | |
6869 | + stroke: gray; | |
6870 | +} | |
6871 | +.messages__item-buttons button:hover svg{ | |
6872 | + color: black; | |
6873 | +} | |
6874 | +.messages__item-buttons button:hover svg path{ | |
6875 | + stroke: black; | |
6876 | +} | |
6877 | +.messages__item-buttons button.pin-on:hover svg#pin_off path{ | |
6878 | + fill: black; | |
6879 | +} | |
6880 | +.messages__item-buttons button.pin-on svg{ | |
6881 | + fill: gray; | |
6882 | +} | |
6883 | +.messages__item-date { | |
6884 | + color: #00000070; | |
6885 | + width: 90px; | |
6886 | + text-align: right; | |
6887 | + font-size: 14px; | |
6888 | + margin-bottom: 8px; | |
6872 | 6889 | } |
6890 | + | |
6873 | 6891 | .messages.active .messages__item { |
6874 | 6892 | display: -webkit-box; |
6875 | 6893 | display: -ms-flexbox; |
... | ... | @@ -9270,3 +9288,32 @@ body .cke_notifications_area{ |
9270 | 9288 | opacity: 0; |
9271 | 9289 | display: none !important; |
9272 | 9290 | } |
9291 | +.unread-messages-count{ | |
9292 | + background-color: #377d87; | |
9293 | + color: #fff; | |
9294 | + padding: 5px 10px; | |
9295 | + border-radius: 45px; | |
9296 | +} | |
9297 | + | |
9298 | +/* Диалог модал */ | |
9299 | +.modal-dialog{ | |
9300 | + border-radius: 10px; | |
9301 | +} | |
9302 | +.modal-dialog .modal-dialog-footer{ | |
9303 | + display: flex; | |
9304 | + justify-content: space-between; | |
9305 | +} | |
9306 | + | |
9307 | +.button-loader { | |
9308 | + border: 2px solid #f3f3f3; | |
9309 | + -webkit-animation: spin 1s linear infinite; | |
9310 | + animation: spin 1s linear infinite; | |
9311 | + border-top: 2px solid #555; | |
9312 | + border-radius: 50%; | |
9313 | + width: 20px; | |
9314 | + height: 20px; | |
9315 | +} | |
9316 | +@keyframes spin { | |
9317 | + 0% { transform: rotate(0deg); } | |
9318 | + 100% { transform: rotate(360deg); } | |
9319 | +} |
public/images/pin_off.svg
... | ... | @@ -0,0 +1,5 @@ |
1 | +<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> | |
2 | +<g opacity="0.25"> | |
3 | +<path d="M21.2011 10.2914L21.1824 10.314L21.1649 10.3376C20.99 10.5746 20.7324 10.7371 20.4432 10.793C20.1586 10.848 19.864 10.7958 19.6158 10.6467C19.566 10.6135 19.4609 10.5439 19.3519 10.4926C19.1996 10.421 18.928 10.3288 18.5951 10.4056C18.3132 10.4706 18.1249 10.6299 18.0531 10.6923C17.9801 10.7556 17.9024 10.8345 17.846 10.8918C17.8405 10.8973 17.8353 10.9026 17.8303 10.9077L17.8302 10.9078C16.4596 12.2971 16.0828 12.6702 14.9413 13.8004L14.9359 13.8058L14.9359 13.8058L14.9324 13.8093L14.4356 14.3061L14.428 14.313C14.4204 14.3199 14.3984 14.3397 14.375 14.3627C14.3742 14.3636 14.3731 14.3646 14.3719 14.3658C14.3397 14.3972 14.1785 14.5544 14.0995 14.8112C13.9963 15.1467 14.0901 15.4255 14.1553 15.5639C14.1964 15.6511 14.2463 15.7242 14.2695 15.7568C15.351 17.4028 14.7366 19.3459 13.5194 20.7627C13.2899 21.0053 13.1747 21.0049 13.1735 21.005L13.1734 21.005C13.1684 21.0052 13.0552 21.0096 12.8172 20.7948C12.4016 20.378 12.024 20.0025 11.6562 19.6368C10.9018 18.8867 10.1885 18.1775 9.27281 17.2356L9.24339 17.2053L9.21618 17.1817C9.21377 17.1792 9.20723 17.1726 9.19271 17.1581L9.19118 17.1565C9.17821 17.1435 9.1224 17.0875 9.04628 17.0331C8.95518 16.9681 8.7878 16.8702 8.55445 16.845C8.32075 16.8198 8.13401 16.8796 8.02355 16.9283C7.92365 16.9723 7.85021 17.0236 7.82313 17.0427C7.7885 17.0672 7.72572 17.116 7.70429 17.1327C7.70063 17.1355 7.69817 17.1374 7.69727 17.1381L7.68381 17.1484L7.67071 17.1592C6.59272 18.0425 5.51225 18.9209 4.42928 19.7942L4.42745 19.7957C3.98373 20.1553 3.53886 20.5154 3.09282 20.8761C3.36515 20.5014 3.63593 20.1278 3.90617 19.755C4.81152 18.5059 5.71082 17.2651 6.64195 16.0186L6.64779 16.0108L6.65348 16.0028C6.65483 16.0009 6.71685 15.9177 6.75922 15.8446C6.80423 15.7669 6.9819 15.4511 6.87009 15.0382C6.82226 14.8617 6.73858 14.738 6.68865 14.6728C6.64133 14.611 6.59536 14.5652 6.58044 14.5503L6.58003 14.5499C6.55113 14.5211 6.54482 14.5154 6.54153 14.5124C6.53888 14.51 6.53818 14.5093 6.52929 14.5L6.51846 14.4885L6.50728 14.4774C5.26496 13.246 4.40387 12.3826 3.28693 11.2608L3.28694 11.2608L3.28235 11.2563C3.00584 10.9821 3.01246 10.8459 3.01285 10.838L3.01285 10.8379C3.01346 10.8247 3.02458 10.6779 3.33148 10.4114L3.33302 10.4101C3.98754 9.8393 4.88968 9.39798 5.81255 9.24909C6.72641 9.10166 7.59019 9.24843 8.27406 9.74538C8.30815 9.77067 8.33536 9.7888 8.34843 9.7975L8.34985 9.79845L9.03635 10.2561L9.61608 9.66903C10.8598 8.40952 12.1109 7.15723 13.3691 5.91223L13.9796 5.30825L13.4748 4.61355C13.2798 4.34531 13.1929 4.01358 13.2312 3.68422C13.2695 3.35486 13.4303 3.05194 13.6816 2.8356C13.9328 2.61926 14.2563 2.5053 14.5877 2.51636C14.9187 2.5274 15.2334 2.66232 15.4696 2.89438C17.8126 5.21499 18.8157 6.22172 21.1333 8.55807C21.3566 8.78708 21.4873 9.09063 21.5001 9.41029C21.513 9.73088 21.4065 10.0449 21.2011 10.2914Z" stroke="black" stroke-width="2"/> | |
4 | +</g> | |
5 | +</svg> |
public/images/pin_on.svg
... | ... | @@ -0,0 +1,5 @@ |
1 | +<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> | |
2 | +<g opacity="0.5"> | |
3 | +<path d="M21.9695 10.9314C21.6456 11.3703 21.1685 11.6714 20.6329 11.7749C20.0973 11.8784 19.5424 11.7767 19.0783 11.4901C18.8233 11.3214 18.8233 11.3251 18.542 11.6101C17.1658 13.0051 16.787 13.3801 15.6395 14.5164L15.1258 15.0301C15.0444 15.1051 15.0305 15.1025 15.092 15.1876C16.5545 17.3889 15.6245 19.8564 14.2633 21.4314C13.5714 22.175 12.8533 22.187 12.1258 21.5176C10.8617 20.2494 9.92903 19.3453 8.55578 17.9326C8.42453 17.8186 8.48116 17.7976 8.30453 17.9326C7.22453 18.8176 6.14203 19.6976 5.05703 20.5726C4.40453 21.1014 3.74953 21.6314 3.09203 22.1626C2.88997 22.3572 2.62566 22.4741 2.34578 22.4926C2.23653 22.4905 2.12881 22.4665 2.02898 22.4221C1.92915 22.3776 1.83923 22.3136 1.76453 22.2339C1.23953 21.7201 1.62953 21.1839 1.79828 20.9551C3.14716 19.1068 4.46266 17.2651 5.84078 15.4201C5.94053 15.281 5.92441 15.3155 5.80328 15.1876C4.55866 13.9539 3.69578 13.0888 2.57828 11.9664C1.78703 11.1819 1.83203 10.3891 2.67578 9.65639C4.25828 8.27639 6.96953 7.55639 8.86703 8.94014C8.88203 8.95139 8.89328 8.95889 8.90453 8.96639C10.151 7.70413 11.4048 6.44911 12.6658 5.20139C12.3233 4.73012 12.1706 4.14733 12.2379 3.56868C12.3052 2.99004 12.5876 2.45786 13.0291 2.07778C13.4706 1.69769 14.0388 1.49749 14.621 1.51692C15.2033 1.53634 15.7569 1.77397 16.172 2.18264C18.5195 4.50764 19.5245 5.51639 21.8458 7.85639C22.2436 8.2626 22.4765 8.80199 22.4993 9.37008C22.5222 9.93817 22.3334 10.4945 21.9695 10.9314Z" fill="black"/> | |
4 | +</g> | |
5 | +</svg> |
public/images/sprite.svg
... | ... | @@ -287,4 +287,4 @@ |
287 | 287 | <path d="M19.9985 24.4905C20.3837 24.4905 20.6985 24.3683 20.9429 24.1239C21.1874 23.8794 21.3096 23.5646 21.3096 23.1795C21.3096 22.7943 21.1874 22.4788 20.9429 22.233C20.6985 21.9885 20.3837 21.8663 19.9985 21.8663C19.6134 21.8663 19.2986 21.9885 19.0542 22.233C18.8097 22.4788 18.6875 22.7943 18.6875 23.1795C18.6875 23.5632 18.8097 23.878 19.0542 24.1239C19.2986 24.3683 19.6134 24.4905 19.9985 24.4905ZM19.9985 18.1783C20.3013 18.1783 20.5549 18.076 20.7596 17.8713C20.9628 17.6681 21.0644 17.4151 21.0644 17.1124V6.28936C21.0644 5.98522 20.9628 5.73154 20.7596 5.52831C20.5549 5.32508 20.3013 5.22346 19.9985 5.22346C19.6958 5.22346 19.4422 5.32508 19.2375 5.52831C19.0343 5.73154 18.9327 5.98522 18.9327 6.28936V17.1124C18.9327 17.4151 19.0343 17.6681 19.2375 17.8713C19.4422 18.076 19.6958 18.1783 19.9985 18.1783ZM7.372 29.9841L3.73944 33.6167C3.20081 34.1553 2.57833 34.279 1.872 33.9876C1.16567 33.6963 0.8125 33.1669 0.8125 32.3994V3.58199C0.8125 2.60137 1.14151 1.78277 1.79952 1.12618C2.4561 0.468166 3.27471 0.13916 4.25533 0.13916H35.7418C36.7224 0.13916 37.541 0.468166 38.1976 1.12618C38.8556 1.78277 39.1846 2.60137 39.1846 3.58199V26.5413C39.1846 27.5219 38.8563 28.3412 38.1997 28.9992C37.5417 29.6558 36.7224 29.9841 35.7418 29.9841H7.372ZM6.46173 27.8523H35.7418C36.0686 27.8523 36.3692 27.7159 36.6435 27.443C36.9164 27.1688 37.0528 26.8682 37.0528 26.5413V3.58199C37.0528 3.25512 36.9164 2.95454 36.6435 2.68025C36.3692 2.40738 36.0686 2.27094 35.7418 2.27094H4.25533C3.92846 2.27094 3.62787 2.40738 3.35359 2.68025C3.08072 2.95454 2.94428 3.25512 2.94428 3.58199V31.3591L6.46173 27.8523Z" fill="currentColor"/> |
288 | 288 | </symbol> |
289 | 289 | |
290 | -</svg> | |
291 | 290 | \ No newline at end of file |
291 | +</svg> |
public/js/func.js
... | ... | @@ -0,0 +1,12 @@ |
1 | + | |
2 | +var spinStart = function(button) { | |
3 | + button.prop('disabled', true); | |
4 | + if (!button.find('.button-loader').length){ | |
5 | + button.html('<div class="button-loader"></div>' + button.html()); | |
6 | + } | |
7 | +}; | |
8 | + | |
9 | +var spinStop= function(button) { | |
10 | + button.prop('disabled', false); | |
11 | + button.find('.button-loader').remove(); | |
12 | +}; |
resources/views/chats/chats_list.blade.php
... | ... | @@ -0,0 +1,100 @@ |
1 | +@if ($chats->count()) | |
2 | + @csrf | |
3 | + @foreach($chats as $chat) | |
4 | + <div class="messages__item hover-shadow {{ intval($chat->is_fixed) == 1 ? 'chat-fixed' : '' }}"> | |
5 | + <div class="messages__item-info"> | |
6 | + <div class="messages__item-photo"> | |
7 | + <a class="" href="{{ route($user_type . '.dialog', ['user1' => $chat->user_id, 'user2' => $chat->to_user_id, 'ad_employer' => 0]) }}"> | |
8 | + @if (isset($chat->employer->logo)) | |
9 | + <img src="{{ asset(Storage::url($chat->employer->logo)) }}" alt=""> | |
10 | + @elseif(isset($chat->worker->photo)) | |
11 | + <img src="{{ asset(Storage::url($chat->worker->photo)) }}" alt=""> | |
12 | + @else | |
13 | + <img src="{{ asset('images/default_man.jpg') }}" alt=""> | |
14 | + @endif | |
15 | + </a> | |
16 | + </div> | |
17 | + <div class="messages__item-text"> | |
18 | + <div> | |
19 | + <a class="messages__item-target" href="{{ route($user_type . '.dialog', ['user1' => $chat->user_id, 'user2' => $chat->to_user_id, 'ad_employer' => 0]) }}"> | |
20 | + <b> | |
21 | + @if ($chat->employer && $chat->employer->name_company) | |
22 | + {{ $chat->employer->name_company }} | |
23 | + @else | |
24 | + {{ $chat->user->surname . ' ' . $chat->user->name_man . ' ' . $chat->user->surname2 }} | |
25 | + @endif | |
26 | + </b> | |
27 | + </a> | |
28 | + </div> | |
29 | + <div> | |
30 | + {{ $chat->last_message->text }} | |
31 | + </div> | |
32 | + </div> | |
33 | + </div> | |
34 | + | |
35 | + <div class="messages__item-actions" data-chat-id="{{ $chat->id }}"> | |
36 | + <div class="messages__item-date max-content">{{ date(' H:i, d.m.Y', strtotime($chat->created_at)) }}</div> | |
37 | + <div class="messages__item-buttons"> | |
38 | + @if($chat->unread_messages_count > 0) | |
39 | + <div class="unread-messages-count mr-15">{{ $chat->unread_messages_count }}</div> | |
40 | + @endif | |
41 | + | |
42 | + <button class="pin-chat {{ intval($chat->is_fixed) == 1 ? 'pin-on' : 'pin-off' }} mr-15"> | |
43 | + @include('svg.pin_off') | |
44 | + </button> | |
45 | + <button class="remove-chat" data-fancybox data-src="#remove_chat"> | |
46 | + <svg> | |
47 | + <use xlink:href="{{ asset('images/sprite.svg#del') }}"></use> | |
48 | + </svg> | |
49 | + </button> | |
50 | + </div> | |
51 | + <div class="clear"></div> | |
52 | + </div> | |
53 | + </div> | |
54 | + @endforeach | |
55 | + <div style="margin-top: 20px"> | |
56 | + {{ $chats->onEachSide(0)->appends($_GET)->links('paginate') }} | |
57 | + </div><!-- конец --> | |
58 | +@else | |
59 | + <div class="notify"> | |
60 | + <svg> | |
61 | + <use xlink:href="{{ asset('images/sprite.svg#i') }}"></use> | |
62 | + </svg> | |
63 | + <span>Сообщений не найдено</span> | |
64 | + </div> | |
65 | +@endif | |
66 | + | |
67 | +<script> | |
68 | + $(function (){ | |
69 | + $('.pin-chat').click(function(){ | |
70 | + var this_btn = $(this); | |
71 | + var chat_id = this_btn.closest('.messages__item-actions').data('chat-id'); | |
72 | + var $is_fixed = this_btn.hasClass('pin-on') ? 0 : 1; | |
73 | + | |
74 | + $.ajax({ | |
75 | + type: "POST", | |
76 | + url: "{{ route('employer.pin_chat') }}", | |
77 | + data: { | |
78 | + id: chat_id, | |
79 | + is_fixed: $is_fixed | |
80 | + }, | |
81 | + headers: { | |
82 | + 'X-CSRF-TOKEN': $('[name="_token"]').val() | |
83 | + }, | |
84 | + success: function(){ | |
85 | + location.reload(); | |
86 | + } | |
87 | + }); | |
88 | + }); | |
89 | + | |
90 | + $('.remove-chat').click(function(){ | |
91 | + var this_btn = $(this); | |
92 | + var chat_id = this_btn.closest('.messages__item-actions').data('chat-id'); | |
93 | + var wrap = this_btn.closest('.messages__item'); | |
94 | + var target = wrap.find('.messages__item-target').text(); | |
95 | + | |
96 | + $('#remove_chat').data('chat-id', chat_id); | |
97 | + $('#remove_chat').find('.target-chat').text(target.trim()); | |
98 | + }); | |
99 | + }); | |
100 | +</script> |
resources/views/employers/dialog.blade.php
... | ... | @@ -92,15 +92,6 @@ |
92 | 92 | </div> |
93 | 93 | <div class="messages__item-text"> |
94 | 94 | <div>{{ $companion->surname." ".$companion->name_man." ".$companion->surname2." (".$companion->id.")" }} </div> |
95 | - <div><span>Вакансия:</span> | |
96 | - @if ($ad_employer == 0) | |
97 | - @if (isset($_GET['ad_name'])){{ $_GET['ad_name'] }}@else Не указано @endif | |
98 | - @else | |
99 | - <a href="{{ route('vacancie', ['vacancy' => $ad_employer]) }}"> | |
100 | - @if (isset($_GET['ad_name'])){{ $_GET['ad_name'] }} ({{ $ad_employer }}) @else Не указано @endif | |
101 | - </a> | |
102 | - @endif | |
103 | - </div> | |
104 | 95 | </div> |
105 | 96 | </div> |
106 | 97 | @if (isset($companion->workers[0]->id)) |
resources/views/employers/messages.blade.php
1 | 1 | @extends('layout.frontend', ['title' => 'Сообщения от пользователей - РекаМоре']) |
2 | 2 | @section('scripts') |
3 | - <script> | |
4 | - console.log('Test system'); | |
5 | - $(document).on('change', '#sort_ajax', function() { | |
6 | - var this_ = $(this); | |
7 | - var val_ = this_.val(); | |
8 | - console.log('sort items '+val_); | |
9 | 3 | |
10 | - $.ajax({ | |
11 | - type: "GET", | |
12 | - url: "{{ route('shipping_companies') }}", | |
13 | - data: "sort="+val_+"&block=1", | |
14 | - success: function (data) { | |
15 | - console.log('Выбор сортировки'); | |
16 | - console.log(data); | |
17 | - $('#block_1').html(data); | |
18 | - }, | |
19 | - headers: { | |
20 | - 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') | |
21 | - }, | |
22 | - error: function (data) { | |
23 | - data = JSON.stringify(data); | |
24 | - console.log('Error: ' + data); | |
25 | - } | |
26 | - }); | |
27 | - | |
28 | - $.ajax({ | |
29 | - type: "GET", | |
30 | - url: "{{ route('shipping_companies') }}", | |
31 | - data: "sort="+val_+"&block=2", | |
32 | - success: function (data) { | |
33 | - console.log('Выбор сортировки2'); | |
34 | - console.log(data); | |
35 | - history.pushState({}, '', "{{ route('shipping_companies') }}?sort="+val_+"@if (isset($_GET['page']))&page={{ $_GET['page'] }}@endif"); | |
36 | - $('#block_2').html(data); | |
37 | - }, | |
38 | - headers: { | |
39 | - 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') | |
40 | - }, | |
41 | - error: function (data) { | |
42 | - data = JSON.stringify(data); | |
43 | - console.log('Error: ' + data); | |
44 | - } | |
45 | - }); | |
46 | - }); | |
47 | - </script> | |
48 | 4 | @endsection |
49 | 5 | |
50 | 6 | @section('content') |
... | ... | @@ -69,158 +25,9 @@ |
69 | 25 | <h2 class="title cabinet__title">Сообщения</h2> |
70 | 26 | </div> |
71 | 27 | <div class="cabinet__body-item"> |
72 | - <div class="cabinet__filters"> | |
73 | - <div class="cabinet__filters-item"> | |
74 | - <div class="cabinet__filters-buttons"> | |
75 | - <a href="{{ route('employer.messages', ['type_message' => 'input']) }}" class="button button_light @if ($type_message == 'input') active @endif">Входящие ({{ $count_input }})</a> | |
76 | - <a href="{{ route('employer.messages', ['type_message' => 'output']) }}" class="button button_light @if ($type_message == 'output') active @endif">Исходящие ({{ $count_output }})</a> | |
77 | - </div> | |
78 | - </div> | |
79 | - <!--<div class="cabinet__filters-item"> | |
80 | - <div class="select"> | |
81 | - <select class="js-select2" id="sort_ajax" name="sort_ajax"> | |
82 | - <option value="default">Сортировка (по умолчанию)</option> | |
83 | - <option value="name (asc)">По имени (возрастание)</option> | |
84 | - <option value="name (desc)">По имени (убывание)</option> | |
85 | - <option value="created_at (asc)">По дате (возрастание)</option> | |
86 | - <option value="created_at (desc)">По дате (убывание)</option> | |
87 | - </select> | |
88 | - </div> | |
89 | - </div>--> | |
90 | - </div> | |
91 | 28 | <div class="messages"> |
92 | - <!--<button type="button" class="messages__button js-toggle js-parent-toggle button button_light button_more"> | |
93 | - <span>Показать ещё</span> | |
94 | - <span>Скрыть</span> | |
95 | - </button>--> | |
96 | 29 | <div class="messages__body"> |
97 | - @if ($messages->count()) | |
98 | - @foreach($messages as $it) | |
99 | - <div class="messages__item"> | |
100 | - <div class="messages__item-info"> | |
101 | - <div class="messages__item-photo"> | |
102 | - <svg> | |
103 | - <use xlink:href="{{ asset('images/sprite.svg#pic') }}"></use> | |
104 | - </svg> | |
105 | - @if ($type_message == 'input') | |
106 | - @if (isset($it->user_from->is_worker)) | |
107 | - @if ($it->user_from->is_worker) | |
108 | - @if (isset($it->user_from->workers[0]->photo)) | |
109 | - <img src="{{ asset(Storage::url($it->user_from->workers[0]->photo)) }}" alt=""> | |
110 | - @else | |
111 | - <img src="{{ asset('images/default_man.jpg') }}" alt=""> | |
112 | - @endif | |
113 | - @else | |
114 | - @if (isset($it->user_from->employers[0]->logo)) | |
115 | - <img src="{{ asset(Storage::url($it->user_from->employers[0]->logo)) }}" alt=""> | |
116 | - @else | |
117 | - <img src="{{ asset('images/default_man.jpg') }}" alt=""> | |
118 | - @endif | |
119 | - @endif | |
120 | - @else | |
121 | - <img src="{{ asset('images/default_man.jpg') }}" alt=""> | |
122 | - @endif | |
123 | - @endif | |
124 | - | |
125 | - @if ($type_message == 'output') | |
126 | - @if (isset($it->user_from->is_worker)) | |
127 | - @if ($it->user_from->is_worker) | |
128 | - @if (isset($it->user_from->workers[0]->photo)) | |
129 | - <img src="{{ asset(Storage::url($it->user_from->workers[0]->photo)) }}" alt=""> | |
130 | - @else | |
131 | - <img src="{{ asset('images/default_man.jpg') }}" alt=""> | |
132 | - @endif | |
133 | - @else | |
134 | - @if (isset($it->user_from->employers[0]->logo)) | |
135 | - <img src="{{ asset(Storage::url($it->user_from->employers[0]->logo)) }}" alt=""> | |
136 | - @else | |
137 | - <img src="{{ asset('images/default_man.jpg') }}" alt=""> | |
138 | - @endif | |
139 | - @endif | |
140 | - @else | |
141 | - <img src="{{ asset('images/default_man.jpg') }}" alt=""> | |
142 | - @endif | |
143 | - @endif | |
144 | - </div> | |
145 | - <div class="messages__item-text"> | |
146 | - <div> | |
147 | - От: @if (isset($it->user_from)) | |
148 | - @if ($it->user_from->id !== $user_id) | |
149 | - <!--<a href=" route('employer.dialog', ['user1' => $user_id, 'user2' => $it->user_from->id]) }}" style="text-decoration: underline">--> | |
150 | - {{ $it->user_from->surname." ".$it->user_from->name_man." ".$it->user_from->surname2." (".$it->user_from->id.")" }} | |
151 | - <!--</a>--> | |
152 | - @else | |
153 | - {{ $it->user_from->surname." ".$it->user_from->name_man." ".$it->user_from->surname2." (".$it->user_from->id.")" }} | |
154 | - @endif | |
155 | - @else | |
156 | - Удаленный пользователь | |
157 | - @endif | |
158 | - <br> | |
159 | - К: @if (isset($it->user_to)) | |
160 | - @if ($it->user_to->id !== $user_id) | |
161 | - <!--<a href=" route('employer.dialog', ['user1' => $user_id, 'user2' => $it->user_to->id]) }}" style="text-decoration: underline">--> | |
162 | - {{ $it->user_to->surname." ".$it->user_to->name_man." ".$it->user_to->surname2." (".$it->user_to->id.")" }} | |
163 | - <!--</a>--> | |
164 | - @else | |
165 | - {{ $it->user_to->surname." ".$it->user_to->name_man." ".$it->user_to->surname2." (".$it->user_to->id.")" }} | |
166 | - @endif | |
167 | - @else | |
168 | - Удаленный пользователь | |
169 | - @endif | |
170 | - </div> | |
171 | - <div> | |
172 | - <span>Вакансия: </span> | |
173 | - @if (isset($it->user_from)) | |
174 | - @if ($it->user_from->id !== $user_id) | |
175 | - @if (isset($it->vacancies)) | |
176 | - <a href="{{ route('employer.dialog', ['user1' => $user_id, 'user2' => $it->user_from->id, 'ad_employer' => $it->vacancies->id, 'ad_name' => $it->vacancies->name ]) }}" style="text-decoration: underline"> | |
177 | - {{ $it->vacancies->name." (".($it->vacancies->id).")" }} | |
178 | - </a> | |
179 | - @else | |
180 | - <a href="{{ route('employer.dialog', ['user1' => $user_id, 'user2' => $it->user_from->id, 'ad_employer' => 0, 'ad_name' => 'Не указана вакансия' ]) }}" style="text-decoration: underline"> | |
181 | - Вакансия не указана | |
182 | - </a> | |
183 | - @endif | |
184 | - @else | |
185 | - | |
186 | - @endif | |
187 | - @endif | |
188 | - | |
189 | - @if (isset($it->user_to)) | |
190 | - @if ($it->user_to->id !== $user_id) | |
191 | - @if (isset($it->vacancies)) | |
192 | - <a href="{{ route('employer.dialog', ['user1' => $user_id, 'user2' => $it->user_to->id, 'ad_employer' => $it->vacancies->id, 'ad_name' => $it->vacancies->name ]) }}" style="text-decoration: underline"> | |
193 | - {{ $it->vacancies->name." (".($it->vacancies->id).")" }} | |
194 | - </a> | |
195 | - @else | |
196 | - <a href="{{ route('employer.dialog', ['user1' => $user_id, 'user2' => $it->user_to->id, 'ad_employer' => 0, 'ad_name' => 'Не указана вакансия' ]) }}" style="text-decoration: underline"> | |
197 | - Вакансия не указана | |
198 | - </a> | |
199 | - @endif | |
200 | - @else | |
201 | - | |
202 | - @endif | |
203 | - @endif | |
204 | - | |
205 | - </div> | |
206 | - <div><span>Текст:</span>{{ $it->text }}</div> | |
207 | - </div> | |
208 | - </div> | |
209 | - | |
210 | - <div class="messages__item-date">{{ $it->created_at }}</div> | |
211 | - </div> | |
212 | - @endforeach | |
213 | - <div style="margin-top: 20px"> | |
214 | - {{ $messages->onEachSide(0)->appends($_GET)->links('paginate') }} | |
215 | - </div><!-- конец --> | |
216 | - @else | |
217 | - <div class="notify"> | |
218 | - <svg> | |
219 | - <use xlink:href="{{ asset('images/sprite.svg#i') }}"></use> | |
220 | - </svg> | |
221 | - <span>Сообщений не найдено</span> | |
222 | - </div> | |
223 | - @endif | |
30 | + @include('chats.chats_list') | |
224 | 31 | </div> |
225 | 32 | </div> |
226 | 33 | </div> |
... | ... | @@ -228,5 +35,5 @@ |
228 | 35 | </div> |
229 | 36 | </div> |
230 | 37 | </section> |
231 | - </div> | |
38 | + @include('modals.chats.remove_chat') | |
232 | 39 | @endsection |
resources/views/layout/frontend.blade.php
... | ... | @@ -8,6 +8,7 @@ |
8 | 8 | <meta name="theme-color" content="#377D87"> |
9 | 9 | <script src="{{ asset('js/jquery.js') }}"></script> |
10 | 10 | <script src="{{ asset('js/jquery-ui.js') }}"></script> |
11 | + <script src="{{ asset('js/func.js') }}"></script> | |
11 | 12 | <link rel="stylesheet" href="{{ asset('js/chosen/chosen.min.css') }}"> |
12 | 13 | <script src="{{ asset('js/chosen/chosen.jquery.min.js') }}"></script> |
13 | 14 | <!--<script type="text/javascript" src=" asset('js/jquery.cookie.js') }}"></script>--> |
resources/views/modals/chats/remove_chat.blade.php
... | ... | @@ -0,0 +1,36 @@ |
1 | +<div id="remove_chat" class="modal-dialog"> | |
2 | + <div class="modal-dialog-title"> | |
3 | + <h2>Удалить чат</h2> | |
4 | + </div> | |
5 | + <div class="modal-dialog-body"> | |
6 | + <p>Вы действительно хотите удалить час с "<b><span class="target-chat"></span></b>"?</p> | |
7 | + </div> | |
8 | + <div class="modal-dialog-footer"> | |
9 | + <button type="button" class="button remove-chat-button">Удалить</button> | |
10 | + <button type="button" class="button button_light" onclick="$.fancybox.close();">Закрыть</button> | |
11 | + </div> | |
12 | +</div> | |
13 | + | |
14 | +<script> | |
15 | + $(function(){ | |
16 | + $('.remove-chat-button').click(function(){ | |
17 | + spinStart($(this)); | |
18 | + var wrap = $(this).closest('#remove_chat'); | |
19 | + var chat_id = wrap.data('chat-id'); | |
20 | + | |
21 | + $.ajax({ | |
22 | + type: "POST", | |
23 | + url: "{{ route('employer.remove_chat') }}", | |
24 | + data: { | |
25 | + id: chat_id | |
26 | + }, | |
27 | + headers: { | |
28 | + 'X-CSRF-TOKEN': $('[name="_token"]').val() | |
29 | + }, | |
30 | + success: function(){ | |
31 | + location.reload(); | |
32 | + } | |
33 | + }); | |
34 | + }); | |
35 | + }); | |
36 | +</script> |
resources/views/svg/pin_off.blade.php
... | ... | @@ -0,0 +1,5 @@ |
1 | +<svg id="pin_off" width="24" height="24" viewBox="0 0 24 24" fill="none"> | |
2 | + <g> | |
3 | + <path d="M21.2011 10.2914L21.1824 10.314L21.1649 10.3376C20.99 10.5746 20.7324 10.7371 20.4432 10.793C20.1586 10.848 19.864 10.7958 19.6158 10.6467C19.566 10.6135 19.4609 10.5439 19.3519 10.4926C19.1996 10.421 18.928 10.3288 18.5951 10.4056C18.3132 10.4706 18.1249 10.6299 18.0531 10.6923C17.9801 10.7556 17.9024 10.8345 17.846 10.8918C17.8405 10.8973 17.8353 10.9026 17.8303 10.9077L17.8302 10.9078C16.4596 12.2971 16.0828 12.6702 14.9413 13.8004L14.9359 13.8058L14.9359 13.8058L14.9324 13.8093L14.4356 14.3061L14.428 14.313C14.4204 14.3199 14.3984 14.3397 14.375 14.3627C14.3742 14.3636 14.3731 14.3646 14.3719 14.3658C14.3397 14.3972 14.1785 14.5544 14.0995 14.8112C13.9963 15.1467 14.0901 15.4255 14.1553 15.5639C14.1964 15.6511 14.2463 15.7242 14.2695 15.7568C15.351 17.4028 14.7366 19.3459 13.5194 20.7627C13.2899 21.0053 13.1747 21.0049 13.1735 21.005L13.1734 21.005C13.1684 21.0052 13.0552 21.0096 12.8172 20.7948C12.4016 20.378 12.024 20.0025 11.6562 19.6368C10.9018 18.8867 10.1885 18.1775 9.27281 17.2356L9.24339 17.2053L9.21618 17.1817C9.21377 17.1792 9.20723 17.1726 9.19271 17.1581L9.19118 17.1565C9.17821 17.1435 9.1224 17.0875 9.04628 17.0331C8.95518 16.9681 8.7878 16.8702 8.55445 16.845C8.32075 16.8198 8.13401 16.8796 8.02355 16.9283C7.92365 16.9723 7.85021 17.0236 7.82313 17.0427C7.7885 17.0672 7.72572 17.116 7.70429 17.1327C7.70063 17.1355 7.69817 17.1374 7.69727 17.1381L7.68381 17.1484L7.67071 17.1592C6.59272 18.0425 5.51225 18.9209 4.42928 19.7942L4.42745 19.7957C3.98373 20.1553 3.53886 20.5154 3.09282 20.8761C3.36515 20.5014 3.63593 20.1278 3.90617 19.755C4.81152 18.5059 5.71082 17.2651 6.64195 16.0186L6.64779 16.0108L6.65348 16.0028C6.65483 16.0009 6.71685 15.9177 6.75922 15.8446C6.80423 15.7669 6.9819 15.4511 6.87009 15.0382C6.82226 14.8617 6.73858 14.738 6.68865 14.6728C6.64133 14.611 6.59536 14.5652 6.58044 14.5503L6.58003 14.5499C6.55113 14.5211 6.54482 14.5154 6.54153 14.5124C6.53888 14.51 6.53818 14.5093 6.52929 14.5L6.51846 14.4885L6.50728 14.4774C5.26496 13.246 4.40387 12.3826 3.28693 11.2608L3.28694 11.2608L3.28235 11.2563C3.00584 10.9821 3.01246 10.8459 3.01285 10.838L3.01285 10.8379C3.01346 10.8247 3.02458 10.6779 3.33148 10.4114L3.33302 10.4101C3.98754 9.8393 4.88968 9.39798 5.81255 9.24909C6.72641 9.10166 7.59019 9.24843 8.27406 9.74538C8.30815 9.77067 8.33536 9.7888 8.34843 9.7975L8.34985 9.79845L9.03635 10.2561L9.61608 9.66903C10.8598 8.40952 12.1109 7.15723 13.3691 5.91223L13.9796 5.30825L13.4748 4.61355C13.2798 4.34531 13.1929 4.01358 13.2312 3.68422C13.2695 3.35486 13.4303 3.05194 13.6816 2.8356C13.9328 2.61926 14.2563 2.5053 14.5877 2.51636C14.9187 2.5274 15.2334 2.66232 15.4696 2.89438C17.8126 5.21499 18.8157 6.22172 21.1333 8.55807C21.3566 8.78708 21.4873 9.09063 21.5001 9.41029C21.513 9.73088 21.4065 10.0449 21.2011 10.2914Z" stroke="black" stroke-width="2"/> | |
4 | + </g> | |
5 | +</svg> |
resources/views/svg/pin_on.blade.php
... | ... | @@ -0,0 +1,5 @@ |
1 | +<svg id="pin_on" width="24" height="24" viewBox="0 0 24 24" fill="none"> | |
2 | + <g> | |
3 | + <path d="M21.9695 10.9314C21.6456 11.3703 21.1685 11.6714 20.6329 11.7749C20.0973 11.8784 19.5424 11.7767 19.0783 11.4901C18.8233 11.3214 18.8233 11.3251 18.542 11.6101C17.1658 13.0051 16.787 13.3801 15.6395 14.5164L15.1258 15.0301C15.0444 15.1051 15.0305 15.1025 15.092 15.1876C16.5545 17.3889 15.6245 19.8564 14.2633 21.4314C13.5714 22.175 12.8533 22.187 12.1258 21.5176C10.8617 20.2494 9.92903 19.3453 8.55578 17.9326C8.42453 17.8186 8.48116 17.7976 8.30453 17.9326C7.22453 18.8176 6.14203 19.6976 5.05703 20.5726C4.40453 21.1014 3.74953 21.6314 3.09203 22.1626C2.88997 22.3572 2.62566 22.4741 2.34578 22.4926C2.23653 22.4905 2.12881 22.4665 2.02898 22.4221C1.92915 22.3776 1.83923 22.3136 1.76453 22.2339C1.23953 21.7201 1.62953 21.1839 1.79828 20.9551C3.14716 19.1068 4.46266 17.2651 5.84078 15.4201C5.94053 15.281 5.92441 15.3155 5.80328 15.1876C4.55866 13.9539 3.69578 13.0888 2.57828 11.9664C1.78703 11.1819 1.83203 10.3891 2.67578 9.65639C4.25828 8.27639 6.96953 7.55639 8.86703 8.94014C8.88203 8.95139 8.89328 8.95889 8.90453 8.96639C10.151 7.70413 11.4048 6.44911 12.6658 5.20139C12.3233 4.73012 12.1706 4.14733 12.2379 3.56868C12.3052 2.99004 12.5876 2.45786 13.0291 2.07778C13.4706 1.69769 14.0388 1.49749 14.621 1.51692C15.2033 1.53634 15.7569 1.77397 16.172 2.18264C18.5195 4.50764 19.5245 5.51639 21.8458 7.85639C22.2436 8.2626 22.4765 8.80199 22.4993 9.37008C22.5222 9.93817 22.3334 10.4945 21.9695 10.9314Z" fill="gray"/> | |
4 | + </g> | |
5 | +</svg> |
resources/views/workers/dialog.blade.php
... | ... | @@ -90,10 +90,6 @@ |
90 | 90 | <img src="{{ asset('images/default_man.jpg') }}" alt=""> |
91 | 91 | @endif |
92 | 92 | </div> |
93 | - <div class="messages__item-text"> | |
94 | - <div>{{ $companion->surname." ".$companion->name_man." ".$companion->surname2." (".$companion->id.")" }} </div> | |
95 | - <div><span>Вакансия:</span> @if (!is_null($ad_employer)) <a href="{{ route('vacancie', ['vacancy' => $ad_employer->id]) }}">{{ $ad_employer->name}}</a> @else Не указано @endif</div> | |
96 | - </div> | |
97 | 93 | </div> |
98 | 94 | @if (isset($companion->worker->id)) |
99 | 95 | <a href="{{ route('resume_profile', ['worker' => $companion->worker->id]) }}" class="button chatbox__toper-button"> |
resources/views/workers/messages.blade.php
... | ... | @@ -25,129 +25,15 @@ |
25 | 25 | <h2 class="title cabinet__title">Сообщения</h2> |
26 | 26 | </div> |
27 | 27 | <div class="cabinet__body-item"> |
28 | - <div class="cabinet__filters"> | |
29 | - <div class="cabinet__filters-item"> | |
30 | - <div class="cabinet__filters-buttons"> | |
31 | - <a href="{{ route('worker.messages', ['type_message' => 'input']) }}" class="button button_light @if ($type_message == 'input') active @endif">Входящие ({{ $count_input }})</a> | |
32 | - <a href="{{ route('worker.messages', ['type_message' => 'output']) }}" class="button button_light @if ($type_message == 'output') active @endif">Исходящие ({{ $count_output }})</a> | |
33 | - </div> | |
28 | + <div class="messages"> | |
29 | + <div class="messages__body"> | |
30 | + @include('chats.chats_list') | |
34 | 31 | </div> |
35 | - <!--<div class="cabinet__filters-item"> | |
36 | - <div class="select"> | |
37 | - <select class="js-select2" id="sort_ajax" name="sort_ajax"> | |
38 | - <option value="default">Сортировка (по умолчанию)</option> | |
39 | - <option value="name (asc)">По имени (возрастание)</option> | |
40 | - <option value="name (desc)">По имени (убывание)</option> | |
41 | - <option value="created_at (asc)">По дате (возрастание)</option> | |
42 | - <option value="created_at (desc)">По дате (убывание)</option> | |
43 | - </select> | |
44 | - </div> | |
45 | - </div>--> | |
46 | 32 | </div> |
47 | - @if ($messages->count()) | |
48 | - @foreach($messages as $it) | |
49 | - <div class="messages__item"> | |
50 | - <div class="messages__item-info"> | |
51 | - <!--<pre> print_r(asset(Storage::url($it->user_from->employers[0]->logo))) }}</pre>--> | |
52 | - <div class="messages__item-photo"> | |
53 | - <svg> | |
54 | - <use xlink:href="{{ asset('images/sprite.svg#pic') }}"></use> | |
55 | - </svg> | |
56 | - <!-- Комментарий: обновление структуры вывода картинок, все корректное --> | |
57 | - @if ($type_message == 'input') | |
58 | - @if (isset($it->user_from->is_worker)) | |
59 | - @if ($it->user_from->is_worker) | |
60 | - @if (isset($it->user_from->workers[0]->photo)) | |
61 | - <img src="{{ asset(Storage::url($it->user_to->workers[0]->photo)) }}" alt=""> | |
62 | - @else | |
63 | - <img src="{{ asset('images/default_man.jpg') }}" alt=""> | |
64 | - @endif | |
65 | - @else | |
66 | - @if (isset($it->user_from->employers[0]->logo)) | |
67 | - <img src="{{ asset(Storage::url($it->user_from->employers[0]->logo)) }}" alt=""> | |
68 | - @else | |
69 | - <img src="{{ asset('images/default_man.jpg') }}" alt=""> | |
70 | - @endif | |
71 | - @endif | |
72 | - @else | |
73 | - <img src="{{ asset('images/default_man.jpg') }}" alt=""> | |
74 | - @endif | |
75 | - @endif | |
76 | - | |
77 | - <!-- Обновление исходящих сообщений - фотографии компании и работника --> | |
78 | - <!-- коммит 2 --> | |
79 | - @if ($type_message == 'output') | |
80 | - @if (isset($it->user_from->is_worker)) | |
81 | - @if ($it->user_from->is_worker) | |
82 | - @if (isset($it->user_from->workers[0]->photo)) | |
83 | - <img src="{{ asset(Storage::url($it->user_from->workers[0]->photo)) }}" alt=""> | |
84 | - @else | |
85 | - <img src="{{ asset('images/default_man.jpg') }}" alt=""> | |
86 | - @endif | |
87 | - @else | |
88 | - @if (isset($it->user_from->employers->logo)) | |
89 | - <img src="{{ asset(Storage::url($it->user_from->employers->logo)) }}" alt=""> | |
90 | - @else | |
91 | - <img src="{{ asset('images/default_man.jpg') }}" alt=""> | |
92 | - @endif | |
93 | - @endif | |
94 | - @else | |
95 | - <img src="{{ asset('images/default_man.jpg') }}" alt=""> | |
96 | - @endif | |
97 | - @endif | |
98 | - </div> | |
99 | - <div class="messages__item-text"> | |
100 | - <div>@if (isset($it->vacancies)) @php $ad_name = $it->vacancies->name; @endphp @else @php $ad_name = 'Вакансия удалена'; @endphp @endif | |
101 | - От: @if (isset($it->user_from)) | |
102 | - @if ($it->user_from->id !== $user_id) | |
103 | - <a href="{{ route('worker.dialog', ['user1' => $user_id, 'user2' => $it->user_from->id, 'ad_employer' => $it->ad_employer_id, 'ad_name' => $ad_name]) }}" style="text-decoration: underline"> | |
104 | - {{ $it->user_from->surname." ".$it->user_from->name_man." ".$it->user_from->surname2." (".$it->user_from->id.")" }} | |
105 | - </a> | |
106 | - @else | |
107 | - {{ $it->user_from->surname." ".$it->user_from->name_man." ".$it->user_from->surname2." (".$it->user_from->id.")" }} | |
108 | - @endif | |
109 | - @else | |
110 | - Удаленный пользователь | |
111 | - @endif | |
112 | - <br> | |
113 | - К: @if (isset($it->user_to)) | |
114 | - @if ($it->user_to->id !== $user_id) | |
115 | - | |
116 | - <a href="{{ route('worker.dialog', ['user1' => $user_id, 'user2' => $it->user_to->id, 'ad_employer' => $it->ad_employer_id, 'ad_name' => $ad_name]) }}" style="text-decoration: underline"> | |
117 | - {{ $it->user_to->surname." ".$it->user_to->name_man." ".$it->user_to->surname2." (".$it->user_to->id.")" }} | |
118 | - </a> | |
119 | - @else | |
120 | - {{ $it->user_to->surname." ".$it->user_to->name_man." ".$it->user_to->surname2." (".$it->user_to->id.")" }} | |
121 | - @endif | |
122 | - @else | |
123 | - Удаленный пользователь | |
124 | - @endif | |
125 | - </div> | |
126 | - <div><span>Вакансия:</span>@if (isset($it->vacancies)) {{ $it->vacancies->name." (".($it->vacancies->id).")" }} @else Удалена @endif</div> | |
127 | - <div><span>Текст:</span>{{ $it->text }}</div> | |
128 | - </div> | |
129 | - </div> | |
130 | - <div class="messages__item-date">{{ $it->created_at }}</div> | |
131 | - </div> | |
132 | - @endforeach | |
133 | - | |
134 | - <div style="margin-top: 20px"> | |
135 | - {{ $messages->onEachSide(0)->appends($_GET)->links('paginate') }} | |
136 | - </div><!-- конец --> | |
137 | - | |
138 | - @else | |
139 | - <div class="notify"> | |
140 | - <svg> | |
141 | - <use xlink:href="{{ asset('images/sprite.svg#i') }}"></use> | |
142 | - </svg> | |
143 | - <span>Сообщений не найдено</span> | |
144 | - </div> | |
145 | - @endif | |
146 | 33 | </div> |
147 | 34 | </div> |
148 | 35 | </div> |
149 | 36 | </div> |
150 | 37 | </section> |
151 | - </div> | |
152 | - <div> | |
38 | + @include('modals.chats.remove_chat') | |
153 | 39 | @endsection |
routes/web.php
... | ... | @@ -649,6 +649,9 @@ Route::group([ |
649 | 649 | |
650 | 650 | // Отправил сообщение |
651 | 651 | Route::post('сообщение/', [EmployerController::class, 'new_message'])->name('new_message'); |
652 | + | |
653 | + Route::post('pin_chat/', [EmployerController::class, 'pin_chat'])->name('pin_chat'); | |
654 | + Route::post('remove_chat/', [EmployerController::class, 'remove_chat'])->name('remove_chat'); | |
652 | 655 | }); |
653 | 656 | |
654 | 657 | Route::get('TestWorker', [WorkerController::class, 'TestWorker'])->name('TestWorker'); |