changeArchivedStatus($task, 1); } /** * Marks the provided task as unarchived. * * @param VBOTaskTaskregistry $task * * @return void */ public function unarchive(VBOTaskTaskregistry $task) { $this->changeArchivedStatus($task, 0); } /** * Marks the provided task as archived or unarchived. * * @param VBOTaskTaskregistry $task * @param int $status Use 1 to archive, 0 to unarchive. * * @return void */ protected function changeArchivedStatus(VBOTaskTaskregistry $task, int $status) { $isArchived = (int) $task->get('archived'); if ($isArchived === $status) { // nothing to change return; } try { // change the archived status VBOTaskModelTask::getInstance()->update([ 'id' => $task->getID(), 'archived' => $status, ]); } catch (Exception $error) { // ignore and go ahead } } }