@@ -104,6 +104,27 @@ public function data($ticketList = 'active')
104104 });
105105 });
106106 }
107+
108+ if (isset ($ search_fields ['any_text_field ' ])){
109+ $ collection ->where (function ($ query ) use ($ search_fields ){
110+ $ query ->where ('subject ' , 'like ' , '% ' . $ search_fields ['any_text_field ' ] . '% ' )
111+ ->orWhere ('content ' , 'like ' , '% ' . $ search_fields ['any_text_field ' ] . '% ' )
112+ ->orWhere ('intervention ' , 'like ' , '% ' . $ search_fields ['any_text_field ' ] . '% ' )
113+ ->orWhereHas ('attachments ' , function ($ q1 ) use ($ search_fields ){
114+ $ q1 ->where ('original_filename ' , 'like ' , '% ' . $ search_fields ['any_text_field ' ] . '% ' )
115+ ->orWhere ('new_filename ' , 'like ' , '% ' . $ search_fields ['any_text_field ' ] . '% ' )
116+ ->orWhere ('description ' , 'like ' , '% ' . $ search_fields ['any_text_field ' ] . '% ' );
117+ })
118+ ->orWhereHas ('comments ' , function ($ q2 ) use ($ search_fields ) {
119+ $ q2 ->where ('content ' , 'like ' , '% ' . $ search_fields ['any_text_field ' ] . '% ' )
120+ ->orWhereHas ('attachments ' , function ($ q3 ) use ($ search_fields ){
121+ $ q3 ->where ('original_filename ' , 'like ' , '% ' . $ search_fields ['any_text_field ' ] . '% ' )
122+ ->orWhere ('new_filename ' , 'like ' , '% ' . $ search_fields ['any_text_field ' ] . '% ' )
123+ ->orWhere ('description ' , 'like ' , '% ' . $ search_fields ['any_text_field ' ] . '% ' );
124+ });
125+ });
126+ });
127+ }
107128 }
108129
109130 }else {
@@ -721,7 +742,7 @@ public function search_results(Request $request)
721742 session ()->forget ('search_fields ' );
722743
723744 // Check all fields
724- $ a_fields = array_merge ($ this ->a_search_fields_numeric , $ this ->a_search_fields_text , ['list ' , 'start_date ' , 'limit_date ' , 'comments ' , 'attachment_name ' ]);
745+ $ a_fields = array_merge ($ this ->a_search_fields_numeric , $ this ->a_search_fields_text , ['list ' , 'start_date ' , 'limit_date ' , 'comments ' , 'attachment_name ' , ' any_text_field ' ]);
725746 foreach ($ a_fields as $ field ){
726747 if ($ request ->filled ($ field )){
727748 $ search_fields [$ field ] = $ request ->{$ field };
0 commit comments