From b26c5be030c30a8ffad2fe1cf6251c2ff7602a75 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 12 Dec 2019 20:33:14 +0800 Subject: [PATCH] update --- app/Http/Controllers/TicketController.php | 23 +++++++++++++++++++++++ routes/api.php | 1 + 2 files changed, 24 insertions(+) diff --git a/app/Http/Controllers/TicketController.php b/app/Http/Controllers/TicketController.php index 5be228d0..eff54138 100644 --- a/app/Http/Controllers/TicketController.php +++ b/app/Http/Controllers/TicketController.php @@ -65,4 +65,27 @@ class TicketController extends Controller 'data' => true ]); } + + public function reply (Request $request) { + if (empty($request->input('id')) || empty($request->input('message'))) { + abort(500, '参数错误'); + } + $ticket = Ticket::where('id', $request->input('id')) + ->where('user_id', $request->session()->get('id')) + ->first(); + if (!$ticket) { + abort(500, '工单不存在'); + } + $ticketMessage = TicketMessage::create([ + 'user_id' => $request->session()->get('id'), + 'ticket_id' => $ticket->id, + 'message' => $request->input('message') + ]); + if (!$ticketMessage) { + abort(500, '工单回复失败'); + } + return response([ + 'data' => true + ]); + } } diff --git a/routes/api.php b/routes/api.php index 644219b8..a813260f 100755 --- a/routes/api.php +++ b/routes/api.php @@ -83,6 +83,7 @@ Route::prefix('v1') // Ticket Route::get ('ticket', 'TicketController@index'); Route::post('ticket/save', 'TicketController@save'); + Route::post('ticket/reply', 'TicketController@reply'); }); // Passport