/**
  *
  * Get the Tickets Reply
  * @param String $message Ticket body
  * @param Integer $ticketId Ticket ID
  * @return Json Response
  *
  */
 private function replyTickets($message, $ticketId)
 {
     $user = Session::get('user');
     $count = adminUserTickets::where('ticketid', $ticketId)->count();
     if ($count == 0) {
         $adminUt = new adminUserTickets();
         $adminUt->ticketid = $ticketId;
         $adminUt->adminid = $user->id;
         $adminUt->save();
     } else {
         $count = adminUserTickets::where('adminid', $user->id)->where('ticketid', $ticketId)->count();
         if ($count == 0) {
             return response()->json(['message' => 'Invalid Request', 'code' => 'error']);
         }
     }
     if (!is_null(trim($message)) && !is_null($ticketId)) {
         $ticket = tickets::find($ticketId);
         if (is_null($ticket)) {
             return response()->json(['message' => 'Invalid Request', 'code' => 'error']);
         }
         if ($ticket->opened == 0) {
             return response()->json(['message' => 'Ticket Should be opened', 'code' => 'error']);
         }
         $ticketMsg = new tickets_messages();
         $ticketMsg->user_id = Session::get('userid');
         $ticketMsg->message = $message;
         $ticketMsg->ticket_id = $ticket->id;
         $ticketMsg->save();
         return response()->json(['code' => 'success', 'task' => 'replyTickets', 'msg' => $ticketMsg]);
     } else {
         return response()->json(['message' => 'Invalid Request', 'code' => 'error']);
     }
 }