errorPresupuestoModel = model(ErrorPresupuestoModel::class); } public function index() { $this->viewData['breadcrumb'] = [ ['title' => lang("App.menu_configuration"), 'route' => "javascript:void(0);", 'active' => false], ['title' => lang("App.menu_error_presupuesto"), 'route' => site_url('configuracion/errores-presupuesto'), 'active' => true] ]; return view(static::$viewPath . $this->indexRoute, $this->viewData); } public function viewForm(int $error_presupuesto_id) { $this->viewData['breadcrumb'] = [ ['title' => lang("App.menu_configuration"), 'route' => "javascript:void(0);", 'active' => false], ['title' => lang("App.menu_error_presupuesto"), 'route' => site_url('configuracion/errores-presupuesto'), 'active' => true] ]; $this->viewData["error_presupuesto_id"] = $error_presupuesto_id; $this->errorPresupuestoModel->update($error_presupuesto_id, [ "last_user_id" => auth()->user()->id, "visto" => true, ]); return view(static::$viewPath . 'viewErrorPresupuestoForm', $this->viewData); } 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->getErrorPresupuestoForm($error_presupuesto_id); if (isset($data[0])) { return $this->response->setJSON(["data" => $data[0]]); } else { return $this->response->setJSON(["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()->orderBy("created_at", "DESC"); return DataTable::of($query) ->add("action", fn($q) => $q->id) ->toJson(true); } }