style: auto-fix 1340 phpcs PSR-12 violations via phpcbf; exclude MissingNamespace and SideEffects
This commit is contained in:
@@ -1,23 +1,28 @@
|
||||
<?php
|
||||
|
||||
require_once 'models/CommentModel.php';
|
||||
|
||||
class CommentController {
|
||||
class CommentController
|
||||
{
|
||||
private $commentModel;
|
||||
|
||||
public function __construct($conn) {
|
||||
|
||||
public function __construct($conn)
|
||||
{
|
||||
$this->commentModel = new CommentModel($conn);
|
||||
}
|
||||
|
||||
public function getCommentsByTicketId($ticketId) {
|
||||
|
||||
public function getCommentsByTicketId($ticketId)
|
||||
{
|
||||
return $this->commentModel->getCommentsByTicketId($ticketId);
|
||||
}
|
||||
|
||||
public function addComment($ticketId) {
|
||||
|
||||
public function addComment($ticketId)
|
||||
{
|
||||
// Check if this is an AJAX request
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
// Get JSON data
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
|
||||
|
||||
// Validate input
|
||||
if (empty($data['comment_text'])) {
|
||||
header('Content-Type: application/json');
|
||||
@@ -27,10 +32,10 @@ class CommentController {
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Add comment
|
||||
$result = $this->commentModel->addComment($ticketId, $data);
|
||||
|
||||
|
||||
// Return JSON response
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($result);
|
||||
@@ -40,4 +45,4 @@ class CommentController {
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user