Commit b1ea22485acd2a54c45e6af94be66aa35bc3e4c0

Authored by Hayk Nazaryan
1 parent b31627c31c
Exists in master

fix job titles

Showing 1 changed file with 28 additions and 7 deletions Side-by-side Diff

app/Http/Controllers/MainController.php
... ... @@ -38,15 +38,20 @@ class MainController extends Controller
38 38 ->OrderByDesc('created_at')
39 39 ->GroupBy('categories.id')
40 40 ->get();
  41 + $Ad_employer=Ad_employer::query()->where('is_remove', 0)
  42 + ->where('active_is', 1)->pluck('id');
41 43  
42   - $Job_title = Job_title::query()->where('is_remove', '=', '0')->
43   - where('is_bd', '=', '0')->orderByDesc('sort')->get();
  44 + $Job_title = Job_title::query()->where('is_remove', '=', '0')
  45 + ->whereHas('Ads', function ($query) use ($Ad_employer) {
  46 + $query->whereIn('ad_employers.id', $Ad_employer);
  47 + })->where('is_bd', '=', '0')->orderByDesc('sort')->get();
44 48  
45 49 $Data = DB::table('job_titles')->
46 50 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')->
47 51 where('categories.is_remove', '=', '0')->
48 52 where('job_titles.is_remove', '=', '0')->
49   - where('job_titles.is_bd', '=' , '0')->
  53 + where('job_titles.is_bd', '=' , '0')
  54 + ->whereIn('ad_jobs.ad_employer_id', $Ad_employer) ->
50 55 leftJoin('ad_jobs', 'ad_jobs.job_title_id', '=', 'job_titles.id')->
51 56 join('categories', 'categories.id', '=', 'job_titles.position_id')->
52 57 groupBy('job_titles.id')->orderBy('categories.id')->orderByDesc('job_titles.position_id')->
... ... @@ -136,10 +141,19 @@ class MainController extends Controller
136 141  
137 142 public function vacancies(Request $request) {
138 143 //должности
  144 +
  145 + $Ad_employer=Ad_employer::query()->where('is_remove', 0)
  146 + ->where('active_is', 1)->pluck('id');
  147 +
  148 +
139 149 $Job_title = Job_title::query()->where('is_remove', '=', '0')->
140   - where('is_bd', '=', '0')->orderByDesc('sort')->
  150 + where('is_bd', '=', '0')
  151 + ->whereHas('Ads', function ($query) use ($Ad_employer) {
  152 + $query->whereIn('ad_employers.id', $Ad_employer);
  153 + })->orderByDesc('sort')->
141 154 orderBy('name')->get();
142 155  
  156 +
143 157 $categories = Category::query()->selectRaw('count(ad_employers.id) as cnt, categories.*')
144 158 ->selectRaw('min(ad_employers.salary) as min_salary, max(ad_employers.salary) as max_salary')
145 159 ->join('ad_employers', 'ad_employers.category_id', '=', 'categories.id')
... ... @@ -155,8 +169,10 @@ class MainController extends Controller
155 169 $Data = DB::table('job_titles')->
156 170 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')->
157 171 where('categories.is_remove', '=', '0')->
158   - where('job_titles.is_bd', '=' , '0')->
159   - where('job_titles.is_remove', '=', '0');
  172 + where('job_titles.is_bd', '=' , '0')
  173 + ->whereIn('ad_jobs.ad_employer_id', $Ad_employer) ->
  174 + where('job_titles.is_remove', '=', '0')
  175 + ;
160 176  
161 177 if (($request->has('job')) && ($request->get('job') > 0)) {
162 178 $Data->where('job_title_id', $request->get('job'));
... ... @@ -168,6 +184,7 @@ class MainController extends Controller
168 184 ->orderBy('categories.id')
169 185 ->orderByDesc('job_titles.position_id')
170 186 ->orderByDesc('job_titles.sort')
  187 + ->whereIn('ad_jobs.ad_employer_id', $Ad_employer)
171 188 ->get()
172 189 ->toArray();
173 190  
... ... @@ -231,9 +248,13 @@ class MainController extends Controller
231 248 default: $Query = $Query->orderbyDesc('updated_at')->orderBy('id'); break;
232 249 }
233 250 }
  251 + $Ad_employer=Ad_employer::query()->where('is_remove', 0)
  252 + ->where('active_is', 1)->pluck('id');
234 253  
235 254 $Job_title = Job_title::query()->where('is_remove', '=', '0')->
236   - where('is_bd', '=', '0')->orderByDesc('sort')->
  255 + where('is_bd', '=', '0')->orderByDesc('sort')->whereHas('Ads', function ($query) use ($Ad_employer) {
  256 + $query->whereIn('ad_employers.id', $Ad_employer);
  257 + })->
237 258 orderBy('name')->get();
238 259  
239 260 $Query_count = $Query->count();