diff --git a/app/Http/Controllers/Admin/MsgAnswersController.php b/app/Http/Controllers/Admin/MsgAnswersController.php index 46f5c04..a1c4597 100644 --- a/app/Http/Controllers/Admin/MsgAnswersController.php +++ b/app/Http/Controllers/Admin/MsgAnswersController.php @@ -16,7 +16,7 @@ class MsgAnswersController extends Controller public function messages(Request $request) { $find_key = ""; $find_cat = ""; - $Msgs = Message::with('user_from')->with('user_to')->with('response'); + $Msgs = Message::with('user_from')->with('user_to'); //->with('response'); $Msgs = $this->filter($Msgs, $request, $find_key, $find_cat); diff --git a/app/Http/Controllers/EmployerController.php b/app/Http/Controllers/EmployerController.php index cf4a0d4..52b4b59 100644 --- a/app/Http/Controllers/EmployerController.php +++ b/app/Http/Controllers/EmployerController.php @@ -349,7 +349,6 @@ class EmployerController extends Controller with('user_to')->where('user_id', $user_id)-> OrderByDesc('created_at'); - $count_input = $messages_input->count(); $count_output = $messages_output->count(); @@ -535,6 +534,8 @@ class EmployerController extends Controller $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', @@ -564,7 +565,9 @@ class EmployerController extends Controller $params['file'] = $request->file('file')->store("messages", 'public'); } Message::create($params); - return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]); + //return redirect()->route('employer.dialog', ['user1' => $user1, 'user2' => $user2]); + return redirect()->route('employer.dialog', + ['user1' => $user1, 'user2' => $user2, 'ad_employer' => $id_vacancy, 'ad_name' => $ad_name]); } } diff --git a/app/Http/Controllers/MainController.php b/app/Http/Controllers/MainController.php index c53efc6..f72e360 100644 --- a/app/Http/Controllers/MainController.php +++ b/app/Http/Controllers/MainController.php @@ -94,7 +94,7 @@ class MainController extends Controller whereHas('employer', function ($query) { $query->where('status_hidden', '=', '0'); })-> - orderBy('id')->limit(8)->get(); + orderBy('sort')->get(); $vacancy = Ad_jobs::query()->with('job_title')->orderBy('position_ship')->get(); return view('index', compact('news', 'Job_title', 'categories', 'employers', 'vacancy', 'Main_Job')); } diff --git a/app/Http/Controllers/WorkerController.php b/app/Http/Controllers/WorkerController.php index 85bc62a..05e5738 100644 --- a/app/Http/Controllers/WorkerController.php +++ b/app/Http/Controllers/WorkerController.php @@ -166,7 +166,7 @@ class WorkerController extends Controller $status_work = $this->status_work; $Query = Worker::query()->with('users')->with('job_titles') ->with('place_worker')->with('sertificate')->with('prev_company') - ->with('infobloks'); + ->with('infobloks')->with('response'); $Query = $Query->where('id', '=', $worker->id); $Query = $Query->get(); @@ -187,9 +187,10 @@ class WorkerController extends Controller $status = $crt->save(); } $stat = Static_worker::query()->where('year_month', '=', $get_date) - ->where('user_id', '=', $worker->id) + ->where('user_id', '=', $worker->user_id) ->get(); - return view('worker', compact('Query', 'status_work', 'idiot')); + + return view('worker', compact('Query', 'status_work', 'idiot', 'stat')); } // скачать анкету соискателя @@ -713,14 +714,16 @@ class WorkerController extends Controller where('id', $user2->id)->first(); } - $Messages = Message::query()->with('response')->where(function($query) use ($user1, $user2) { + $Messages = Message::query()-> + //with('response')-> + where(function($query) use ($user1, $user2) { $query->where('user_id', $user1->id)->where('to_user_id', $user2->id); })->orWhere(function($query) use ($user1, $user2) { $query->where('user_id', $user2->id)->where('to_user_id', $user1->id); })->OrderBy('created_at')->get(); $id_vac = null; - foreach ($Messages as $it) { + /*foreach ($Messages as $it) { if (isset($it->response)) { foreach ($it->response as $r) { if (isset($r->ad_employer_id)) { @@ -730,7 +733,7 @@ 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(); diff --git a/app/Models/Ad_employer.php b/app/Models/Ad_employer.php index 6c7de72..da5db3e 100644 --- a/app/Models/Ad_employer.php +++ b/app/Models/Ad_employer.php @@ -59,7 +59,6 @@ class Ad_employer extends Model return $this->hasMany(Category::class, 'id'); } - public function scopeActive($query) { return $query->where('is_remove', '=', '0'); } diff --git a/app/Models/ResponseWork.php b/app/Models/ResponseWork.php index 1671a83..b65d00c 100644 --- a/app/Models/ResponseWork.php +++ b/app/Models/ResponseWork.php @@ -4,6 +4,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; class ResponseWork extends Model { @@ -14,4 +15,5 @@ class ResponseWork extends Model 'stars', 'message' ]; + } diff --git a/app/Models/Worker.php b/app/Models/Worker.php index a11bd95..cc96210 100644 --- a/app/Models/Worker.php +++ b/app/Models/Worker.php @@ -89,4 +89,8 @@ class Worker extends Model return $this->hasMany(Dop_info::class, 'worker_id'); } + public function response() { + return $this->hasMany(ResponseWork::class); + } + } diff --git a/app/Models/infobloks.php b/app/Models/infobloks.php index fd768aa..8444041 100644 --- a/app/Models/infobloks.php +++ b/app/Models/infobloks.php @@ -18,4 +18,12 @@ class infobloks extends Model public function ScopeActive($query) { return $query->where('is_remove', '=', '0'); } + + /* + * Связь модели Инфоблоки (Infobloks) с моделью Доп.информация (dop_info) + один-ко-многим + */ + public function model_dop_info() { + return $this->hasMany(dop_info::class, 'infoblok_id'); + } } diff --git a/resources/views/admin/messages.blade.php b/resources/views/admin/messages.blade.php index 4a9a1ca..8cb9d46 100644 --- a/resources/views/admin/messages.blade.php +++ b/resources/views/admin/messages.blade.php @@ -18,7 +18,7 @@