Commit 0ea9852237693bc176370331b95f3c1b5a51994c

Authored by Андрей Ларионов
1 parent 748f122fa7

Коммит по диалогам и переписке

Showing 10 changed files with 57 additions and 11 deletions Side-by-side Diff

app/Http/Controllers/EmployerController.php
... ... @@ -348,7 +348,6 @@ class EmployerController extends Controller
348 348 with('user_to')->where('user_id', $user_id)->
349 349 OrderByDesc('created_at');
350 350  
351   -
352 351 $count_input = $messages_input->count();
353 352 $count_output = $messages_output->count();
354 353  
... ... @@ -534,6 +533,8 @@ class EmployerController extends Controller
534 533 $params = $request->all();
535 534 $user1 = $params['user_id'];
536 535 $user2 = $params['to_user_id'];
  536 + $id_vacancy = $params['ad_employer_id'];
  537 + $ad_name = $params['ad_name'];
537 538  
538 539 $rules = [
539 540 'text' => 'required|min:1|max:150000',
... ... @@ -563,7 +564,9 @@ class EmployerController extends Controller
563 564 $params['file'] = $request->file('file')->store("messages", 'public');
564 565 }
565 566 Message::create($params);
566   - return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]);
  567 + //return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]);
  568 + return redirect()->route('employer.dialog',
  569 + ['user1' => $user1, 'user2' => $user2, 'ad_employer' => $id_vacancy, 'ad_name' => $ad_name]);
567 570  
568 571 }
569 572 }
app/Http/Controllers/MainController.php
... ... @@ -94,7 +94,7 @@ class MainController extends Controller
94 94 whereHas('employer', function ($query) {
95 95 $query->where('status_hidden', '=', '0');
96 96 })->
97   - orderBy('id')->limit(8)->get();
  97 + orderBy('sort')->get();
98 98 $vacancy = Ad_jobs::query()->with('job_title')->orderBy('position_ship')->get();
99 99 return view('index', compact('news', 'Job_title', 'categories', 'employers', 'vacancy', 'Main_Job'));
100 100 }
app/Http/Controllers/WorkerController.php
... ... @@ -166,7 +166,7 @@ class WorkerController extends Controller
166 166 $status_work = $this->status_work;
167 167 $Query = Worker::query()->with('users')->with('job_titles')
168 168 ->with('place_worker')->with('sertificate')->with('prev_company')
169   - ->with('infobloks');
  169 + ->with('infobloks')->with('response');
170 170 $Query = $Query->where('id', '=', $worker->id);
171 171 $Query = $Query->get();
172 172  
... ... @@ -187,9 +187,10 @@ class WorkerController extends Controller
187 187 $status = $crt->save();
188 188 }
189 189 $stat = Static_worker::query()->where('year_month', '=', $get_date)
190   - ->where('user_id', '=', $worker->id)
  190 + ->where('user_id', '=', $worker->user_id)
191 191 ->get();
192   - return view('worker', compact('Query', 'status_work', 'idiot'));
  192 +
  193 + return view('worker', compact('Query', 'status_work', 'idiot', 'stat'));
193 194 }
194 195  
195 196 // скачать анкету соискателя
... ... @@ -712,14 +713,16 @@ class WorkerController extends Controller
712 713 where('id', $user2->id)->first();
713 714 }
714 715  
715   - $Messages = Message::query()->with('response')->where(function($query) use ($user1, $user2) {
  716 + $Messages = Message::query()->
  717 + //with('response')->
  718 + where(function($query) use ($user1, $user2) {
716 719 $query->where('user_id', $user1->id)->where('to_user_id', $user2->id);
717 720 })->orWhere(function($query) use ($user1, $user2) {
718 721 $query->where('user_id', $user2->id)->where('to_user_id', $user1->id);
719 722 })->OrderBy('created_at')->get();
720 723  
721 724 $id_vac = null;
722   - foreach ($Messages as $it) {
  725 + /*foreach ($Messages as $it) {
723 726 if (isset($it->response)) {
724 727 foreach ($it->response as $r) {
725 728 if (isset($r->ad_employer_id)) {
... ... @@ -729,7 +732,7 @@ class WorkerController extends Controller
729 732 }
730 733 }
731 734 if (!is_null($id_vac)) break;
732   - }
  735 + }*/
733 736  
734 737 $ad_employer = null;
735 738 if (!is_null($id_vac)) $ad_employer = Ad_employer::query()->where('id', $id_vac)->first();
app/Models/ResponseWork.php
... ... @@ -4,6 +4,7 @@ namespace App\Models;
4 4  
5 5 use Illuminate\Database\Eloquent\Factories\HasFactory;
6 6 use Illuminate\Database\Eloquent\Model;
  7 +use Illuminate\Database\Eloquent\Relations\BelongsTo;
7 8  
8 9 class ResponseWork extends Model
9 10 {
... ... @@ -14,4 +15,5 @@ class ResponseWork extends Model
14 15 'stars',
15 16 'message'
16 17 ];
  18 +
17 19 }
app/Models/Worker.php
... ... @@ -89,4 +89,8 @@ class Worker extends Model
89 89 return $this->hasMany(Dop_info::class, 'worker_id');
90 90 }
91 91  
  92 + public function response() {
  93 + return $this->hasMany(ResponseWork::class);
  94 + }
  95 +
92 96 }
resources/views/employers/dialog.blade.php
... ... @@ -182,6 +182,8 @@
182 182 <input type="hidden" name="_token" value="{{ csrf_token() }}"/>
183 183 <input type="hidden" id="user_id" name="user_id" value="{{ $sender->id }}"/>
184 184 <input type="hidden" id="to_user_id" name="to_user_id" value="{{ $companion->id }}"/>
  185 + <input type="hidden" id="ad_employer_id" name="ad_employer_id" value="{{ $ad_employer }}"/>
  186 + <input type="hidden" id="ad_name" name="ad_name" value="@if (isset($_GET['ad_name'])){{ $_GET['ad_name'] }} @endif"/>
185 187 <input id="text" name="text" type="text" class="input chatbox__bottom-text" placeholder="Ответить">
186 188 <button type="submit" id="send_btn" name="send_btn" class="chatbox__bottom-send">
187 189 <svg>
resources/views/modals/send_worker_new.blade.php
... ... @@ -32,6 +32,9 @@
32 32 <input type="text" id="send_to_user_id" name="send_to_user_id" class="input" placeholder="to_user_id" value="">
33 33 Вакансия:
34 34 <input type="text" id="send_vacancy" name="send_vacancy" class="input" placeholder="vacancy" value="">
  35 + Должность:
  36 + <input type="text" id="send_job_title_id" name="send_job_title_id" class="input" placeholder="vacancy" value="0">
  37 +
35 38 </div>
36 39 <div class="modal__form-item send_title_div error_">
37 40 <input id="send_title" name="send_title" type="text" class="input" placeholder="Тема" required>
resources/views/worker.blade.php
... ... @@ -294,6 +294,35 @@
294 294 </div>
295 295 </div>
296 296  
  297 + <div class="main__resume-profile-info">
  298 + <h2 class="main__resume-profile-info-title">Количество просмотров страницы: ({{ $stat[0]->lookin }})</h2>
  299 + </div>
  300 +
  301 + <div class="main__resume-profile-info">
  302 + <h2 class="main__resume-profile-info-title">Отзывы о работнике ({{ $Query[0]->response->count() }})</h2>
  303 + <div class="main__resume-profile-info-body">
  304 + @if ((isset($Query[0]->response)) && ($Query[0]->response->count()))
  305 + <div class="main__resume-profile-info-body-item">
  306 + <ul class="main__resume-profile-info-body-inner">
  307 + @php $i = 1; @endphp
  308 + @foreach($Query[0]->response as $it)
  309 + <li>
  310 + <span><h3>Комментарий №{{$i}}</h3></span>
  311 + <span><b>Оценка человека: {{ $it->stars }}</b></span>
  312 + <span><b>Сообщение: </b>{{ $it->message }}</span>
  313 + </li>
  314 + @php $i++; @endphp
  315 + @endforeach
  316 + </ul>
  317 + </div>
  318 + @else
  319 + <div class="main__resume-profile-info-body-item">
  320 + <h3 class="main__resume-profile-info-body-subtitle">Нету комментариев</h3>
  321 + </div>
  322 + @endif
  323 + </div>
  324 + </div>
  325 +
297 326 <div class="main__resume-profile-review">
298 327 <form action="{{ route('stars_answer') }}" method="POST">
299 328 @csrf
resources/views/workers/cabinet.blade.php
... ... @@ -203,7 +203,7 @@
203 203 <use xlink:href="{{ asset('images/sprite.svg#warning') }}"></use>
204 204 </svg>
205 205 <span>Отзывов:</span>
206   - <b>@if (isset($stat[0]->message)) {{ $stat[0]->message }} @else 0 @endif</b>
  206 + <b>@if(isset($Worker[0]->response)) {{ $Worker[0]->response->count() }} @else 0 @endif</b>
207 207 </div>
208 208 </div>
209 209 <div class="cabinet__stats-subtitle">Анкета заполнена на {{ $persent }}%</div>
resources/views/workers/messages.blade.php
... ... @@ -112,7 +112,7 @@
112 112 Удаленный пользователь
113 113 @endif
114 114 </div>
115   - <div><span>Вакансия:</span>@if (isset($it->vacancies[0])) {{ $it->vacancies[0]->name." (".($it->vacancies[0]->id).")" }} @else Удалена @endif</div>
  115 + <div><span>Вакансия:</span>@if (isset($it->vacancies)) {{ $it->vacancies->name." (".($it->vacancies->id).")" }} @else Удалена @endif</div>
116 116 <div><span>Текст:</span>{{ $it->text }}</div>
117 117 </div>
118 118 </div>