@@ -34,7 +34,7 @@ class TicketsController extends Controller
3434 protected $ tickets ;
3535 protected $ member ;
3636 protected $ a_search_fields_numeric = ['creator_id ' , 'user_id ' , 'status_id ' , 'priority_id ' , 'category_id ' , 'agent_id ' ];
37- protected $ a_search_fields_text = ['subject ' , 'html ' , 'intervention_html ' ];
37+ protected $ a_search_fields_text = ['subject ' , 'content ' , 'intervention ' ];
3838 protected $ a_search_fields_date = ['start_date ' , 'limit_date ' , 'created_at ' , 'completed_at ' , 'updated_at ' ];
3939
4040 public function __construct (Ticket $ tickets , \PanicHDMember $ member )
@@ -95,7 +95,21 @@ public function data($ticketList = 'active')
9595 }
9696
9797 }elseif (in_array ($ field , $ this ->a_search_fields_text )){
98- $ collection ->where ($ field , 'like ' , '% ' . $ value . '% ' );
98+ if ($ field == 'content ' ){
99+ $ collection ->where (function ($ query ) use ($ search_fields , $ value ){
100+ $ query ->where ('content ' , 'like ' , '% ' . $ value . '% ' )
101+ ->orWhere ('html ' , 'like ' , '% ' . $ value . '% ' );
102+ });
103+
104+ }elseif ($ field == 'intervention ' ){
105+ $ collection ->where (function ($ query ) use ($ search_fields , $ value ){
106+ $ query ->where ('intervention ' , 'like ' , '% ' . $ value . '% ' )
107+ ->orWhere ('intervention_html ' , 'like ' , '% ' . $ value . '% ' );
108+ });
109+
110+ }else {
111+ $ collection ->where ($ field , 'like ' , '% ' . $ value . '% ' );
112+ }
99113
100114 }elseif (in_array ($ field , $ this ->a_search_fields_numeric )){
101115 $ collection ->where ($ field , $ value );
@@ -110,7 +124,8 @@ public function data($ticketList = 'active')
110124
111125 if (isset ($ search_fields ['comments ' ])){
112126 $ collection ->whereHas ('comments ' , function ($ q1 ) use ($ search_fields ){
113- $ q1 ->where ('content ' , 'like ' , '% ' . $ search_fields ['comments ' ] . '% ' );
127+ $ q1 ->where ('content ' , 'like ' , '% ' . $ search_fields ['comments ' ] . '% ' )
128+ ->orWhere ('html ' , 'like ' , '% ' . $ search_fields ['comments ' ] . '% ' );
114129 });
115130 }
116131
@@ -134,15 +149,18 @@ public function data($ticketList = 'active')
134149 if (isset ($ search_fields ['any_text_field ' ])){
135150 $ collection ->where (function ($ query ) use ($ search_fields ){
136151 $ query ->where ('subject ' , 'like ' , '% ' . $ search_fields ['any_text_field ' ] . '% ' )
152+ ->orWhere ('content ' , 'like ' , '% ' . $ search_fields ['any_text_field ' ] . '% ' )
137153 ->orWhere ('html ' , 'like ' , '% ' . $ search_fields ['any_text_field ' ] . '% ' )
154+ ->orWhere ('intervention ' , 'like ' , '% ' . $ search_fields ['any_text_field ' ] . '% ' )
138155 ->orWhere ('intervention_html ' , 'like ' , '% ' . $ search_fields ['any_text_field ' ] . '% ' )
139156 ->orWhereHas ('attachments ' , function ($ q1 ) use ($ search_fields ){
140157 $ q1 ->where ('original_filename ' , 'like ' , '% ' . $ search_fields ['any_text_field ' ] . '% ' )
141158 ->orWhere ('new_filename ' , 'like ' , '% ' . $ search_fields ['any_text_field ' ] . '% ' )
142159 ->orWhere ('description ' , 'like ' , '% ' . $ search_fields ['any_text_field ' ] . '% ' );
143160 })
144161 ->orWhereHas ('comments ' , function ($ q2 ) use ($ search_fields ) {
145- $ q2 ->where ('html ' , 'like ' , '% ' . $ search_fields ['any_text_field ' ] . '% ' )
162+ $ q2 ->where ('content ' , 'like ' , '% ' . $ search_fields ['any_text_field ' ] . '% ' )
163+ ->orWhere ('html ' , 'like ' , '% ' . $ search_fields ['any_text_field ' ] . '% ' )
146164 ->orWhereHas ('attachments ' , function ($ q3 ) use ($ search_fields ){
147165 $ q3 ->where ('original_filename ' , 'like ' , '% ' . $ search_fields ['any_text_field ' ] . '% ' )
148166 ->orWhere ('new_filename ' , 'like ' , '% ' . $ search_fields ['any_text_field ' ] . '% ' )
0 commit comments