Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $smartSuitable = Vacancy::
- select(['vacancies.*', 'personal_info.date_of_readiness','personal_info.rank_list_id', \DB::raw("(SELECT MAX(sign_off_date) FROM service WHERE service.user_id = '$user_id' AND service.rank_list_id = personal_info.rank_list_id)")])
- ->join('personal_info', function($join)use($user_id){
- $join->on("personal_info.user_id" ,"=",\DB::raw("'{$user_id}'"));
- })
- ->join('service', function($join)use($user_id){
- $join->on("service.user_id" ,"=",\DB::raw("'{$user_id}'"));
- $join->on("service.rank_list_id" ,"=","personal_info.rank_list_id");
- })
- ->whereRaw('(personal_info.rank_list_id = vacancies.rank_list_id OR service.rank_list_id = vacancies.rank_list_id)')
- ->where('date_of_readiness', '<', 'vacancies.join_date')
- ->whereRaw('salary_expected <= vacancies.salary_max')
- ->where('vacancies.is_smart' , 1)
- ->whereRaw('(YEAR(CURRENT_DATE) - YEAR(personal_info.date_of_birth)) > vacancies.years_old_min')
- ->whereRaw('(YEAR(CURRENT_DATE) - YEAR(personal_info.date_of_birth)) < vacancies.years_old_max')
- ->whereRaw('personal_info.english_proficiency >= vacancies.english_level')
- ->groupBy('vacancies.id')->get();
- return $smartSuitable;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement