public function getTicketReplyById($replyId) { $result = Ticket_reply::whereId($replyId)->first(); //first() function in sql returns the first value of the selected column return $result; }
public function replyOnTicketsPost($id) { $reply = $_POST['val']; $reply = trim(preg_replace('/\\s+/', ' ', $reply)); if (!$reply == "") { // $objTicket = Ticket::getInstance(); // $whereForData = array('rawQuery' => 'ticket_id=?', 'bindParams' => [$id]); // $selectedColumns = ['users.*', 'tickets.*', 'ticket_reply.reply_text','ticket_reply.created_at']; // // $ticketDetails = $objTicket->getUserInfoByTicketId($whereForData, $selectedColumns); // print_r($reply); //// $id = $_POST['ticket_id']; // print_r($id);die; $objMOdelTicket_reply = new Ticket_reply(); // dd($objComment); $input = array('reply_id' => '', 'ticketId' => $id, 'replied_by' => Session::get('ig_user')['id'], 'reply_text' => $reply); // dd($input); // $data = json_encode($input, true); // dd($data); // $result = DB::table('comments')->insert($data); $result = $objMOdelTicket_reply->addNewReply($input); } /*-------------------------------------------------*/ // $objTicket = Ticket::getInstance(); // $whereForData = array('rawQuery' => 'ticket_id=?', 'bindParams' => [$id]); // $selectedColumns = ['users.*', 'tickets.*', 'ticket_reply.reply_text','ticket_reply.created_at']; // // $ticketDetails = $objTicket->getUserInfoByTicketId($whereForData, $selectedColumns); // $countTotalReply = count($ticketDetails); // $i = 0; // foreach($ticketDetails as $t) { //// if (++$i === $countTotalReply) { // $username = $t->username; // $email = $t->email; // $ticket_id = $t->ticket_id; // $subject = $t->subject; // $descriptions = $t->descriptions; // $text = $t->reply_text; //// } // } /*-------------------------*/ // if ($result) { //// $objMailTemplate = new MailTemplate(); //// $temp_name = "forgot_password_mail"; //// $mailTempContent = $objMailTemplate->getTemplateByName($temp_name); // $key = env('MANDRILL_KEY'); // $mandrill = new Mandrill($key); // $async = false; // $ip_pool = 'Main Pool'; // $message = array( // 'html' => "<html><body>Hello!!!*|username|* Reply to your query<br> // Ticket ID: *|ticket_id|*<br> // Subject:*|subject|*<br> // Descriptions:*|descriptions|*<br> // Reply:*|reply_text|*<br> // <br> If You are Satisfied with this reply, Please Close the ticket.</body></html>", // 'subject' => "Reply To your Query", // 'from_email' => "*****@*****.**", // 'to' => array( // array( // 'email' => $email, // 'type' => 'to' // ) // ), // 'merge_vars' => array( // array( // "rcpt" => $email, // 'vars' => array( // array( // "name" => "username", // "content" => $username // ), // array( // "name" => "ticket_id", // "content" => $ticket_id // ), // array( // "name" => "subject", // "content" => $subject // ), // array( // "name" => "descriptions", // "content" => $descriptions // ), // array( // "name" => "reply_text", // "content" => $text // ), // ) // ) // ), // ); // // $mailrespons = $mandrill->messages->send($message, $async, $ip_pool); //// dd($mailrespons); // if ($mailrespons[0]['status'] == "sent") { // return Redirect::back()->with(['status' => 'Success', 'msg' => 'An email has sent to ' . $email . ' regarding the reply.']); // } else { // return Redirect::back()->with(['status' => 'Error', 'msg' => 'Missing Something.']); // } // } // // else { // return Redirect::back()->with(['status' => 'Error', 'msg' => 'This Email is not Registered.']); // //return redirect('admin/forgot'); //// return redirect('admin/forgotpasswordpage')->withErrors([ //// 'errMsg' => 'this email is not registered.' //// ]); // } // // // } }