diff options
Diffstat (limited to 'app/Model/TaskPositionModel.php')
-rw-r--r-- | app/Model/TaskPositionModel.php | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/app/Model/TaskPositionModel.php b/app/Model/TaskPositionModel.php index 9f7eb983..6c109f3d 100644 --- a/app/Model/TaskPositionModel.php +++ b/app/Model/TaskPositionModel.php @@ -12,6 +12,42 @@ use Kanboard\Core\Base; */ class TaskPositionModel extends Base { + public function moveBottom($project_id, $task_id, $swimlane_id, $column_id) + { + $this->db->startTransaction(); + + $task = $this->taskFinderModel->getById($task_id); + + $result = $this->db->table(TaskModel::TABLE) + ->eq('project_id', $project_id) + ->eq('swimlane_id', $swimlane_id) + ->eq('column_id', $column_id) + ->columns('MAX(position) AS pos') + ->findOne(); + + $position = 1; + if (! empty($result)) { + $position = $result['pos'] + 1; + } + + $result = $this->db->table(TaskModel::TABLE) + ->eq('id', $task_id) + ->eq('project_id', $project_id) + ->update([ + 'swimlane_id' => $swimlane_id, + 'column_id' => $column_id, + 'position' => $position + ]); + + $this->db->closeTransaction(); + + if ($result) { + $this->fireEvents($task, $column_id, $position, $swimlane_id); + } + + return $result; + } + /** * Move a task to another column or to another position * |