diff --git a/app/Http/Controllers/EmployerController.php b/app/Http/Controllers/EmployerController.php index ddbeaca..0412fb6 100644 --- a/app/Http/Controllers/EmployerController.php +++ b/app/Http/Controllers/EmployerController.php @@ -163,13 +163,12 @@ class EmployerController extends Controller $id = Auth()->user()->id; $categories = Category::query()->active()->get(); - - if ($categories->count()) { - $jobs = Job_title::query()->OrderBy('name')->where('is_remove', '=', '0')->Notbdif()->where('position_id', $categories[0]->id)->get(); - } else { - $jobs = Job_title::query()->OrderBy('name')->where('is_remove', '=', '0')->Notbdif()->where('position_id', 0)->get(); - } - + //if ($categories->count()) { + // $jobs = Job_title::query()->OrderBy('name')->where('is_remove', '=', '0')->Notbdif()->where('position_id', $categories[0]->id)->get(); + //} else { + // $jobs = Job_title::query()->OrderBy('name')->where('is_remove', '=', '0')->Notbdif()->where('position_id', 0)->get(); + //} + $jobs = Job_title::query()->OrderBy('name')->where('is_remove', '=', '0')->Notbdif()->get(); $Employer = Employer::query()->with('users')->with('ads')->with('flots')-> WhereHas('users', function (Builder $query) use ($id) {$query->Where('id', $id); @@ -180,19 +179,22 @@ class EmployerController extends Controller // Сохранение вакансии public function cabinet_vacancy_save1(VacancyRequestEdit $request) { $params_emp = $request->all(); + $params_job["job_title_id"] = $params_emp['job_title_id']; - $params_job["min_salary"] = $params_emp['min_salary']; - $params_job["max_salary"] = $params_emp['max_salary']; - $params_job["region"] = $params_emp['region']; - $params_job["power"] = $params_emp['power']; - $params_job["sytki"] = $params_emp['sytki']; - $params_job["start"] = $params_emp['start']; - $params_job["flot"] = $params_emp['flot']; + //$params_job["min_salary"] = $params_emp['min_salary']; + //$params_job["max_salary"] = $params_emp['max_salary']; + //$params_job["region"] = $params_emp['region']; + //$params_job["power"] = $params_emp['power']; + //$params_job["sytki"] = $params_emp['sytki']; + //$params_job["start"] = $params_emp['start']; + //$params_job["flot"] = $params_emp['flot']; $params_job["description"] = $params_emp['description']; $ad_jobs = Ad_employer::create($params_emp); - $params_job['ad_employer_id'] = $ad_jobs->id; - Ad_jobs::create($params_job); + //$params_job['ad_employer_id'] = $ad_jobs->id; + //Ad_jobs::create($params_job); + $ad_jobs->jobs()->sync($request->get('job_title_id')); + return redirect()->route('employer.vacancy_list'); } diff --git a/app/Http/Controllers/WorkerController.php b/app/Http/Controllers/WorkerController.php index 7d62fee..2632877 100644 --- a/app/Http/Controllers/WorkerController.php +++ b/app/Http/Controllers/WorkerController.php @@ -278,9 +278,6 @@ class WorkerController extends Controller $persent = $persent + 5; $persent5 = 5; } - - //dd($persent1, $persent2, $persent3, $persent4, $persent5); - if ($request->has('print')) { dd($Worker); } else { diff --git a/app/Models/Ad_employer.php b/app/Models/Ad_employer.php index da6da3e..6c7de72 100644 --- a/app/Models/Ad_employer.php +++ b/app/Models/Ad_employer.php @@ -68,4 +68,9 @@ class Ad_employer extends Model public function ad_job() { return $this->hasMany(Ad_jobs::class); } + + // Связь Вакансии с должностями (0-0 - 1) + public function job_titles() { + return $this->belongsToMany(Job_title::class, 'title_workers'); + } } diff --git a/resources/views/employers/add_vacancy.blade.php b/resources/views/employers/add_vacancy.blade.php index a75d9ef..fb70021 100644 --- a/resources/views/employers/add_vacancy.blade.php +++ b/resources/views/employers/add_vacancy.blade.php @@ -122,29 +122,28 @@ @enderror - -
+
@@ -167,100 +166,126 @@
-
+ + +
+ +
+
+ - @error('job_title_id') - - {{ $message }} - - @enderror
-
+