diff --git a/app/Http/Controllers/MainController.php b/app/Http/Controllers/MainController.php index fbfaae2..54fa08d 100644 --- a/app/Http/Controllers/MainController.php +++ b/app/Http/Controllers/MainController.php @@ -38,15 +38,20 @@ class MainController extends Controller ->OrderByDesc('created_at') ->GroupBy('categories.id') ->get(); + $Ad_employer=Ad_employer::query()->where('is_remove', 0) + ->where('active_is', 1)->pluck('id'); - $Job_title = Job_title::query()->where('is_remove', '=', '0')-> - where('is_bd', '=', '0')->orderByDesc('sort')->get(); + $Job_title = Job_title::query()->where('is_remove', '=', '0') + ->whereHas('Ads', function ($query) use ($Ad_employer) { + $query->whereIn('ad_employers.id', $Ad_employer); + })->where('is_bd', '=', '0')->orderByDesc('sort')->get(); $Data = DB::table('job_titles')-> selectRaw('job_titles.name as jn, count(`ad_jobs`.`job_title_id`) as cnt, job_titles.id as id_job, categories.name as catname, categories.id as id_cat')-> where('categories.is_remove', '=', '0')-> where('job_titles.is_remove', '=', '0')-> - where('job_titles.is_bd', '=' , '0')-> + where('job_titles.is_bd', '=' , '0') + ->whereIn('ad_jobs.ad_employer_id', $Ad_employer) -> leftJoin('ad_jobs', 'ad_jobs.job_title_id', '=', 'job_titles.id')-> join('categories', 'categories.id', '=', 'job_titles.position_id')-> groupBy('job_titles.id')->orderBy('categories.id')->orderByDesc('job_titles.position_id')-> @@ -136,10 +141,19 @@ class MainController extends Controller public function vacancies(Request $request) { //должности + + $Ad_employer=Ad_employer::query()->where('is_remove', 0) + ->where('active_is', 1)->pluck('id'); + + $Job_title = Job_title::query()->where('is_remove', '=', '0')-> - where('is_bd', '=', '0')->orderByDesc('sort')-> + where('is_bd', '=', '0') + ->whereHas('Ads', function ($query) use ($Ad_employer) { + $query->whereIn('ad_employers.id', $Ad_employer); + })->orderByDesc('sort')-> orderBy('name')->get(); + $categories = Category::query()->selectRaw('count(ad_employers.id) as cnt, categories.*') ->selectRaw('min(ad_employers.salary) as min_salary, max(ad_employers.salary) as max_salary') ->join('ad_employers', 'ad_employers.category_id', '=', 'categories.id') @@ -155,8 +169,10 @@ class MainController extends Controller $Data = DB::table('job_titles')-> selectRaw('job_titles.name as jn, count(`ad_jobs`.`job_title_id`) as cnt, job_titles.id as id_job, categories.name as catname, categories.id as id_cat')-> where('categories.is_remove', '=', '0')-> - where('job_titles.is_bd', '=' , '0')-> - where('job_titles.is_remove', '=', '0'); + where('job_titles.is_bd', '=' , '0') + ->whereIn('ad_jobs.ad_employer_id', $Ad_employer) -> + where('job_titles.is_remove', '=', '0') + ; if (($request->has('job')) && ($request->get('job') > 0)) { $Data->where('job_title_id', $request->get('job')); @@ -168,6 +184,7 @@ class MainController extends Controller ->orderBy('categories.id') ->orderByDesc('job_titles.position_id') ->orderByDesc('job_titles.sort') + ->whereIn('ad_jobs.ad_employer_id', $Ad_employer) ->get() ->toArray(); @@ -231,9 +248,13 @@ class MainController extends Controller default: $Query = $Query->orderbyDesc('updated_at')->orderBy('id'); break; } } + $Ad_employer=Ad_employer::query()->where('is_remove', 0) + ->where('active_is', 1)->pluck('id'); $Job_title = Job_title::query()->where('is_remove', '=', '0')-> - where('is_bd', '=', '0')->orderByDesc('sort')-> + where('is_bd', '=', '0')->orderByDesc('sort')->whereHas('Ads', function ($query) use ($Ad_employer) { + $query->whereIn('ad_employers.id', $Ad_employer); + })-> orderBy('name')->get(); $Query_count = $Query->count();