I'm trying to create a text field filter where its value can query back all the data that has the filter value from all column of a table. For now my existing code can only query from column which is the users.name Below is my current code :
$employeeDetails = DB::table('employees')
->join('users', 'users.id', '=', 'employees.user_id')
->leftjoin('cost_centres', 'cost_centres.id', '=', 'employees.cost_centre_id')
->leftjoin('departments', 'departments.id', '=', 'employees.department_id')
->leftjoin('sections', 'sections.id', '=', 'employees.section_id')
->leftjoin('employee_positions', 'employee_positions.id', '=', 'employees.position_id')
->leftjoin('teams', 'teams.id', '=', 'employees.team_id')
->leftjoin('categories', 'categories.id', '=', 'employees.category_id')
->leftjoin('branches', 'branches.id', '=', 'employees.branch_id')
->leftjoin('areas', 'areas.id', '=', 'employees.area_id')
->leftjoin('employee_grades', 'employee_grades.id', '=', 'employees.grade_id')
->leftjoin('attendance_group_area','attendance_group_area.area_id','employees.area_id')
->whereIn('employees.id', $leaveTransactionEmployees)
->where('users.name', 'LIKE', '%'.$filterValue.'%')
->select('employees.*','users.name as name', 'cost_centres.name as costCentre', 'departments.name as department', 'sections.name as section',
'employee_positions.name as position', 'teams.name as team', 'areas.name as area', 'employee_grades.name as grade',
'categories.name as category', 'attendance_group_area.attendance_group_id as attendance_group_id')
->get();
return response()->json($employeeDetails);
as you can see the only the filter I have right now is this and its only filter for 1 column
->where('users.name', 'LIKE', '%'.$filterValue.'%')
How can I use the same value to filter all the column in all the table I leftjoined if the value exist in any of my column.