Commit a9391093225a82ebec92aa95b8f392d323f410a2
1 parent
712f07ca2d
Exists in
master
рефакторинг сообщений
Showing 10 changed files with 63 additions and 9 deletions Side-by-side Diff
- app/Http/Controllers/EmployerController.php
- app/Models/Chat.php
- public/css/style_may2024.css
- public/images/pin_off.svg
- public/images/pin_on.svg
- public/images/sprite.svg
- resources/views/employers/messages.blade.php
- resources/views/svg/pin_off.blade.php
- resources/views/svg/pin_on.blade.php
- resources/views/workers/dialog.blade.php
app/Http/Controllers/EmployerController.php
... | ... | @@ -343,6 +343,9 @@ class EmployerController extends Controller |
343 | 343 | ->with('worker') |
344 | 344 | ->with('employer') |
345 | 345 | ->with('last_message') |
346 | + ->withCount(['unread_messages' => function ($query) use($user_id) { | |
347 | + $query->where('to_user_id', '=', $user_id)->where('flag_new', '=', 1); | |
348 | + }]) | |
346 | 349 | ->where('user_id', '=', $user_id) |
347 | 350 | ->orderByDesc('is_fixed') |
348 | 351 | ->orderByDesc('last_message_date') |
... | ... | @@ -403,6 +406,11 @@ class EmployerController extends Controller |
403 | 406 | //if (!is_null($id_vac)) $ad_employer = Ad_employer::query()->where('id', $id_vac)->first(); |
404 | 407 | $sender = $user1; |
405 | 408 | |
409 | + Message::where('user_id', '=', $user2->id) | |
410 | + ->where('to_user_id', '=', $user1->id) | |
411 | + ->update(['flag_new' => 0]) | |
412 | + ; | |
413 | + | |
406 | 414 | return view('employers.dialog', compact('companion', 'sender', 'ad_employer', 'Messages')); |
407 | 415 | } |
408 | 416 |
app/Models/Chat.php
public/css/style_may2024.css
... | ... | @@ -6866,6 +6866,8 @@ main + .news { |
6866 | 6866 | } |
6867 | 6867 | .messages__item-buttons{ |
6868 | 6868 | float: right; |
6869 | + display: flex; | |
6870 | + align-items: center; | |
6869 | 6871 | } |
6870 | 6872 | .messages__item-buttons button{ |
6871 | 6873 | padding: 0; |
... | ... | @@ -6877,9 +6879,18 @@ main + .news { |
6877 | 6879 | height: 25px; |
6878 | 6880 | color: gray; |
6879 | 6881 | } |
6880 | -.messages__item-buttons button svg:hover{ | |
6882 | +.messages__item-buttons button svg path{ | |
6883 | + stroke: gray; | |
6884 | +} | |
6885 | +.messages__item-buttons button:hover svg{ | |
6881 | 6886 | color: black; |
6882 | 6887 | } |
6888 | +.messages__item-buttons button:hover svg path{ | |
6889 | + stroke: black; | |
6890 | +} | |
6891 | +.messages__item-buttons button:hover svg#pin_on path{ | |
6892 | + fill: black; | |
6893 | +} | |
6883 | 6894 | .messages__item-date { |
6884 | 6895 | color: #00000070; |
6885 | 6896 | width: 90px; |
... | ... | @@ -9288,3 +9299,9 @@ body .cke_notifications_area{ |
9288 | 9299 | opacity: 0; |
9289 | 9300 | display: none !important; |
9290 | 9301 | } |
9302 | +.unread-messages-count{ | |
9303 | + background-color: #377d87; | |
9304 | + color: #fff; | |
9305 | + padding: 5px 10px; | |
9306 | + border-radius: 45px; | |
9307 | +} |
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> |
resources/views/employers/messages.blade.php
... | ... | @@ -74,7 +74,7 @@ |
74 | 74 | @if ($chats->count()) |
75 | 75 | @foreach($chats as $chat) |
76 | 76 | <div class=""> |
77 | - <a class="messages__item hover-shadow" href="{{ route('worker.dialog', ['user1' => $chat->user_id, 'user2' => $chat->to_user_id]) }}"> | |
77 | + <a class="messages__item hover-shadow" href="{{ route('employer.dialog', ['user1' => $chat->user_id, 'user2' => $chat->to_user_id, 'ad_employer' => 0]) }}"> | |
78 | 78 | <div class="messages__item-info"> |
79 | 79 | <div class="messages__item-photo"> |
80 | 80 | @if (isset($chat->worker->photo)) |
... | ... | @@ -102,8 +102,16 @@ |
102 | 102 | <div class="messages__item-actions"> |
103 | 103 | <div class="messages__item-date max-content">{{ date(' H:i, d.m.Y', strtotime($chat->created_at)) }}</div> |
104 | 104 | <div class="messages__item-buttons"> |
105 | - <button class="mr-10"> | |
106 | - <img src="{{ asset("images/icon-pin-empty.png") }}"/> | |
105 | + @if($chat->unread_messages_count > 0) | |
106 | + <div class="unread-messages-count mr-15">{{ $chat->unread_messages_count }}</div> | |
107 | + @endif | |
108 | + | |
109 | + <button class="mr-15"> | |
110 | + @if(intval($chat->is_fixed) == 1) | |
111 | + @include('svg.pin_on') | |
112 | + @else | |
113 | + @include('svg.pin_off') | |
114 | + @endif | |
107 | 115 | </button> |
108 | 116 | <button class=""> |
109 | 117 | <svg> |
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"> |