diff --git a/app/Http/Controllers/WorkerController.php b/app/Http/Controllers/WorkerController.php index 2a9be05..0079d94 100644 --- a/app/Http/Controllers/WorkerController.php +++ b/app/Http/Controllers/WorkerController.php @@ -304,16 +304,11 @@ class WorkerController extends Controller )". ((!empty($jobIds)) ? 'and job_titles.id in ('. implode(',', $jobIds).')' : '') );*/ - $users = DB::select( - "select `job_titles`.`name`, `users`.`surname`, `users`.`name_man`, `users`.`surname2`, `users`.`email`, `users`.`telephone` - from users - join workers on `users`.`id` = `workers`.`user_id` - join `job_titles` - where `users`.`is_bd` = 1 - and (`workers`.`position_work` = `job_titles`.`id` - or `workers`.`positions_work` - )". ((!empty($jobIds)) ? 'and job_titles.id in ('. implode(',', $jobIds).')' : '') - ); + $users = DB::select("SELECT`job_titles`.`name`,`users`.`surname`,`users`.`name_man`,`users`.`surname2`,`users`.`email`,`users`.`telephone` FROM users + JOIN workers ON `users`.`id` = `workers`.`user_id` + JOIN job_titles ON (`workers`.`position_work` = `job_titles`.`id` + OR JSON_CONTAINS(`workers`.`positions_work`, JSON_QUOTE(CAST(`job_titles`.`id` AS CHAR)), '$')) + WHERE `users`.`is_bd` = 1 " . ((!empty($jobIds)) ? 'AND job_titles.id IN (' . implode(',', $jobIds) . ')' : '') . ""); $users = collect($users);