root 5 anos atrás
pai
commit
5cb4fcb908
1 arquivos alterados com 9 adições e 0 exclusões
  1. 9 0
      app/Http/Controllers/TicketController.php

+ 9 - 0
app/Http/Controllers/TicketController.php

@@ -79,6 +79,9 @@ class TicketController extends Controller
         if (!$ticket) {
             abort(500, '工单不存在');
         }
+        if ($request->session()->get('id') == $this->getLastMessage()->user_id) {
+            abort(500, '请等待管理员回复');
+        }
         $ticketMessage = TicketMessage::create([
             'user_id' => $request->session()->get('id'),
             'ticket_id' => $ticket->id,
@@ -91,4 +94,10 @@ class TicketController extends Controller
             'data' => true
         ]);
     }
+
+    private function getLastMessage ($ticketId) {
+        return TicketMessage::where('ticket_id', $ticketId)
+            ->orderBy('id', 'DESC')
+            ->first();
+    }
 }