@@ -85,15 +85,18 @@ class TicketShow extends Component
8585 'confirmed-start-timer ' => 'handleConfirmedStart ' ,
8686 ];
8787
88- protected $ rules = [
89- 'comment ' => 'required|min:5|max:5000 ' ,
90- 'attachments.* ' => 'file|max:10240|mimes:pdf,doc,docx,xls,xlsx,txt,jpg,jpeg,png,gif ' ,
91- 'status ' => 'required|in:Open,In Progress,On Hold,Resolved,Closed ' ,
92- 'priority ' => 'required|in:Low,Medium,High,Critical ' ,
93- 'assignedTo ' => 'nullable|exists:users,id ' ,
94- 'timeSpent ' => 'nullable|numeric|min:0.1|max:999 ' ,
95- 'timeDescription ' => 'required_with:timeSpent|string|max:500 ' ,
96- ];
88+ protected function rules ()
89+ {
90+ return [
91+ 'comment ' => 'required|min:5|max:5000 ' ,
92+ 'attachments.* ' => 'file|max:10240|mimes:pdf,doc,docx,xls,xlsx,txt,jpg,jpeg,png,gif ' ,
93+ 'status ' => 'required| ' .Ticket::getStatusValidationRule (),
94+ 'priority ' => 'required| ' .Ticket::getPriorityValidationRule (),
95+ 'assignedTo ' => 'nullable|exists:users,id ' ,
96+ 'timeSpent ' => 'nullable|numeric|min:0.1|max:999 ' ,
97+ 'timeDescription ' => 'required_with:timeSpent|string|max:500 ' ,
98+ ];
99+ }
97100
98101 protected $ messages = [
99102 'comment.required ' => 'Please enter a comment. ' ,
@@ -219,7 +222,7 @@ public function updateStatus()
219222 {
220223 try {
221224 $ this ->validate ([
222- 'newStatus ' => 'required|in:Open,In Progress,On Hold,Resolved,Closed ' ,
225+ 'newStatus ' => 'required| ' .Ticket:: getStatusValidationRule () ,
223226 'statusChangeReason ' => 'required|min:10|max:500 ' ,
224227 ]);
225228
@@ -261,7 +264,7 @@ public function updateStatus()
261264
262265 public function updatePriority ()
263266 {
264- $ this ->validate (['priority ' => 'required|in:low,medium,high,urgent,critical ' ]);
267+ $ this ->validate (['priority ' => 'required| ' .Ticket:: getPriorityValidationRule () ]);
265268
266269 $ oldPriority = $ this ->ticket ->priority ;
267270 $ this ->ticket ->priority = $ this ->priority ;
@@ -321,15 +324,15 @@ public function toggleWatch()
321324 if ($ watcher ) {
322325 $ watcher ->delete ();
323326 $ this ->ticket ->load ('watchers.user ' );
324-
327+
325328 Flux::toast (
326329 text: 'You are no longer watching this ticket ' ,
327330 variant: 'info '
328331 );
329332 } else {
330333 $ this ->ticket ->watchers ()->create (['user_id ' => Auth::id ()]);
331334 $ this ->ticket ->load ('watchers.user ' );
332-
335+
333336 Flux::toast (
334337 text: 'You are now watching this ticket ' ,
335338 variant: 'success '
@@ -347,7 +350,7 @@ public function deleteComment($commentId)
347350 if ($ comment && $ comment ->created_at ->diffInMinutes (now ()) < 30 ) {
348351 $ comment ->delete ();
349352 $ this ->ticket ->load ('comments.author ' , 'comments.attachments ' );
350-
353+
351354 Flux::toast (
352355 text: 'Comment deleted successfully ' ,
353356 variant: 'success '
@@ -392,7 +395,7 @@ public function updateComment()
392395 $ comment ->update (['content ' => $ this ->editingCommentText ]);
393396 $ this ->reset (['editingCommentId ' , 'editingCommentText ' ]);
394397 $ this ->ticket ->load ('comments.author ' , 'comments.attachments ' );
395-
398+
396399 Flux::toast (
397400 text: 'Comment updated successfully ' ,
398401 variant: 'success '
@@ -426,7 +429,7 @@ public function cloneTicket()
426429 public function archiveTicket ()
427430 {
428431 $ this ->ticket ->update (['archived_at ' => now ()]);
429-
432+
430433 Flux::toast (
431434 text: 'Ticket archived successfully ' ,
432435 variant: 'success '
@@ -444,7 +447,7 @@ public function deleteTimeEntry($timeEntryId)
444447 if ($ entry ) {
445448 $ entry ->delete ();
446449 $ this ->ticket ->load ('timeLogs.user ' );
447-
450+
448451 Flux::toast (
449452 text: 'Time entry deleted successfully ' ,
450453 variant: 'success '
@@ -590,7 +593,7 @@ public function saveDraft()
590593 now ()->addDays (1 )
591594 );
592595 $ this ->draftSaved = true ;
593-
596+
594597 // Reset the draft saved indicator after 2 seconds
595598 $ this ->dispatch ('draftSavedIndicator ' );
596599 }
@@ -641,8 +644,8 @@ public function render()
641644 return view ('livewire.tickets.ticket-show ' , [
642645 'technicians ' => $ technicians ,
643646 'isWatching ' => $ isWatching ,
644- 'statuses ' => [ ' open ' , ' in_progress ' , ' pending ' , ' resolved ' , ' closed ' ] ,
645- 'priorities ' => [ ' low ' , ' medium ' , ' high ' , ' urgent ' , ' critical ' ] ,
647+ 'statuses ' => Ticket:: ALL_STATUSES ,
648+ 'priorities ' => Ticket:: ALL_PRIORITIES ,
646649 ]);
647650 }
648651}
0 commit comments