diff --git a/server/src/Repository/TaskRepository.php b/server/src/Repository/TaskRepository.php index 392d39c..0d138ef 100644 --- a/server/src/Repository/TaskRepository.php +++ b/server/src/Repository/TaskRepository.php @@ -81,14 +81,11 @@ class TaskRepository */ public function updateById($id, $data) { - $task = $this->findOneById($id); - - $stmt = $this->db->getConnection()->prepare('UPDATE ' . $this->tableName . ' SET user_id = :user_id, title = :title, description = :description, creation_date = :creation_date, status = :status'); - $stmt->bindParam(':user_id', $data['user_id'] ?? $task['user_id'], \PDO::PARAM_INT); - $stmt->bindParam(':title', $data['title'] ?? $task['title'], \PDO::PARAM_STR); - $stmt->bindParam(':description', $data['description'] ?? $task['description'], \PDO::PARAM_STR); - $stmt->bindParam(':creation_date', $data['creation_date'] ?? $task['creation_date']); - $stmt->bindParam(':status', $data['status'] ?? $task['status'], \PDO::PARAM_INT); + $stmt = $this->db->getConnection()->prepare('UPDATE ' . $this->tableName . ' SET title = :title, description = :description, status = :status WHERE id = :id'); + $stmt->bindParam(':id', $id, \PDO::PARAM_INT); + $stmt->bindParam(':title', $data['title'], \PDO::PARAM_STR); + $stmt->bindParam(':description', $data['description'], \PDO::PARAM_STR); + $stmt->bindParam(':status', $data['status'], \PDO::PARAM_INT); $stmt->execute(); return $data; diff --git a/server/src/Service/Request.php b/server/src/Service/Request.php index 5053286..ee4ca32 100644 --- a/server/src/Service/Request.php +++ b/server/src/Service/Request.php @@ -8,8 +8,20 @@ namespace App\Service; */ class Request { - public function getContentAsArray() + private $content; + + public function getContent() { - return $content = json_decode(trim(file_get_contents("php://input")), true) ?? []; + $this->content = trim(file_get_contents("php://input")) ?? []; + + return $this; + } + + public function asPlainText(){ + return (string) $this->content; + } + + public function jsonToArray(){ + return json_decode($this->content, true); } } \ No newline at end of file