model = new BlocksModel(); } public function getBlocks($params) { $blocks = $this->model->getBlocks($params); if (empty($blocks)) { http_response_code(404); return $this->response(['message' => 'Blocks not found']); } else return $this->response($blocks); } public function addBlock($params) { $insert_data = (array) $this->post; $result = $this->model->insert($insert_data); if ($result) { return $this->response(['message' => 'success']); } else { return $this->response(['message' => 'error']); } } public function updateBlock($params) { $update_data = (array) $this->post; $conditions = [ 'id' => $params['block_id'] ]; $result = $this->model->update($update_data, $conditions); if ($result) { return $this->response(['message' => 'success']); } else { return $this->response(['message' => 'error']); } } }