diff --git a/app/Http/Controllers/WorkerController.php b/app/Http/Controllers/WorkerController.php index 05e5738..e928dc2 100644 --- a/app/Http/Controllers/WorkerController.php +++ b/app/Http/Controllers/WorkerController.php @@ -389,7 +389,6 @@ class WorkerController extends Controller with('user_to')->where('user_id', $user_id)-> OrderByDesc('created_at'); - $count_input = $messages_input->count(); $count_output = $messages_output->count(); @@ -401,6 +400,7 @@ class WorkerController extends Controller $messages = $messages_output->paginate(5); } + //dd($messages); // Вернуть все 100% return view('workers.messages', compact('messages', 'count_input', 'count_output', 'type_message', 'user_id')); } @@ -707,7 +707,14 @@ class WorkerController extends Controller } //Переписка - public function dialog(User_Model $user1, User_Model $user2) { + public function dialog(User_Model $user1, User_Model $user2, Request $request) { + // Получение параметров. + if ($request->has('ad_employer')){ + $ad_employer = $request->get('ad_employer'); + } else { + $ad_employer = 0; + } + if (isset($user2->id)) { $companion = User_Model::query()->with('workers')-> with('employers')-> @@ -735,10 +742,11 @@ class WorkerController extends Controller if (!is_null($id_vac)) break; }*/ - $ad_employer = null; - if (!is_null($id_vac)) $ad_employer = Ad_employer::query()->where('id', $id_vac)->first(); + //$ad_employer = null; + //if (!is_null($id_vac)) $ad_employer = Ad_employer::query()->where('id', $id_vac)->first(); $sender = $user1; + return view('workers.dialog', compact('companion', 'sender', 'Messages', 'ad_employer')); } @@ -900,6 +908,49 @@ class WorkerController extends Controller return redirect()->route('worker.messages', ['type_message' => 'output']); } + + public function test123(Request $request) { + $params = $request->all(); + $user1 = $params['user_id']; + $user2 = $params['to_user_id']; + $id_vacancy = $params['ad_employer_id']; + $ad_name = $params['ad_name']; + + $rules = [ + 'text' => 'required|min:1|max:150000', + 'file' => 'file|mimes:doc,docx,xlsx,csv,txt,xlx,xls,pdf|max:150000' + ]; + $messages = [ + 'required' => 'Укажите обязательное поле', + 'min' => [ + 'string' => 'Поле «:attribute» должно быть не меньше :min символов', + 'integer' => 'Поле «:attribute» должно быть :min или больше', + 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' + ], + 'max' => [ + 'string' => 'Поле «:attribute» должно быть не больше :max символов', + 'integer' => 'Поле «:attribute» должно быть :max или меньше', + 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' + ] + ]; + + $validator = Validator::make($request->all(), $rules, $messages); + + if ($validator->fails()) { + return redirect()->route('worker.dialog', ['user1' => $user1, 'user2' => $user2, 'ad_employer' => $id_vacancy, 'ad_name' => $ad_name]) + ->withErrors($validator); + } else { + if ($request->has('file')) { + $params['file'] = $request->file('file')->store("messages", 'public'); + } + Message::create($params); + //return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]); + return redirect()->route('worker.dialog', + ['user1' => $user1, 'user2' => $user2, 'ad_employer' => $id_vacancy, 'ad_name' => $ad_name]); + + } + } + // Информация о предыдущих компаниях public function new_prev_company(Worker $worker) { return view('workers.prev_company_form', compact('worker')); diff --git a/resources/views/vacance-item.blade.php b/resources/views/vacance-item.blade.php index 28180c4..1f9206b 100644 --- a/resources/views/vacance-item.blade.php +++ b/resources/views/vacance-item.blade.php @@ -5,7 +5,7 @@ @extends('layout.frontend', ['title' => $title]) @section('scripts') - @include('js.favorite-vacancy') +