errorPresupuestoModel = model(ErrorPresupuestoModel::class); } public function index() { return view(static::$viewPath . $this->indexRoute, $this->viewData); } public function viewForm(int $error_presupuesto_id) { $this->errorPresupuestoModel->update($error_presupuesto_id, [ "last_user_id" => auth()->user()->id ]); return view(static::$viewPath . 'viewErrorPresupuestoForm', ["error_presupuesto_id" => $error_presupuesto_id]); } public function store() { $data = []; $variableCreated = $this->errorPresupuestoModel->store($data); return $this->response->setJSON($variableCreated); } public function get_error_presupuesto(int $error_presupuesto_id) { $data = $this->errorPresupuestoModel->getQueryDatatable() ->where("presupuesto_errores.id", $error_presupuesto_id)->get()->getResultObject()[0]; return $this->response->setJSON(["data" => $data]); } public function update_error_presupuesto(int $error_presupuesto_id) { $bodyData = $this->request->getPost(); $this->errorPresupuestoModel->updateComment($error_presupuesto_id, $bodyData["comments"]); return $this->response->setJSON(["message" => "Comentario actualizado", "status" => true]); } public function datatable() { $query = $this->errorPresupuestoModel->getQueryDatatable(); return DataTable::of($query) ->add("action", fn($q) => $q->id) ->toJson(true); } }