database->query( 'SELECT * FROM board_columns WHERE board_id = :board_id ORDER BY position ASC', ['board_id' => $boardId] ); return array_map(fn(array $r) => BoardColumn::fromRow($r), $rows); } public function maxPosition(int $boardId): int { $row = $this->database->first( 'SELECT MAX(position) AS max_pos FROM board_columns WHERE board_id = :board_id', ['board_id' => $boardId] ); return (int) ($row['max_pos'] ?? -1); } public function insert(BoardColumn $col): BoardColumn { $this->database->execute( 'INSERT INTO board_columns (board_id, name, position, show_card_count, show_export_button, show_card_age, card_age_warning_days, created_at, created_by, updated_at, updated_by) VALUES (:board_id, :name, :position, :show_card_count, :show_export_button, :show_card_age, :card_age_warning_days, :created_at, :created_by, :updated_at, :updated_by)', [ 'board_id' => $col->boardId, 'name' => $col->name, 'position' => $col->position, 'show_card_count' => $col->showCardCount ? 1 : 0, 'show_export_button' => $col->showExportButton ? 1 : 0, 'show_card_age' => $col->showCardAge ? 1 : 0, 'card_age_warning_days' => $col->cardAgeWarningDays, 'created_at' => $col->createdAt, 'created_by' => $col->createdBy, 'updated_at' => $col->updatedAt, 'updated_by' => $col->updatedBy, ] ); $row = $this->database->first('SELECT last_insert_rowid() AS id'); $col->id = (int) ($row['id'] ?? 0); return $col; } public function update(BoardColumn $col): void { $this->database->execute( 'UPDATE board_columns SET name = :name, updated_at = :updated_at, updated_by = :updated_by WHERE id = :id', ['name' => $col->name, 'updated_at' => $col->updatedAt, 'updated_by' => $col->updatedBy, 'id' => $col->id] ); } public function updateShowExportButton(int $id, bool $show, string $updatedAt, string $updatedBy): void { $this->database->execute( 'UPDATE board_columns SET show_export_button = :show_export_button, updated_at = :updated_at, updated_by = :updated_by WHERE id = :id', ['show_export_button' => $show ? 1 : 0, 'updated_at' => $updatedAt, 'updated_by' => $updatedBy, 'id' => $id] ); } public function updateShowCardCount(int $id, bool $show, string $updatedAt, string $updatedBy): void { $this->database->execute( 'UPDATE board_columns SET show_card_count = :show_card_count, updated_at = :updated_at, updated_by = :updated_by WHERE id = :id', ['show_card_count' => $show ? 1 : 0, 'updated_at' => $updatedAt, 'updated_by' => $updatedBy, 'id' => $id] ); } public function updateCardAgeSettings(int $id, bool $showCardAge, int $cardAgeWarningDays, string $updatedAt, string $updatedBy): void { $this->database->execute( 'UPDATE board_columns SET show_card_age = :show_card_age, card_age_warning_days = :card_age_warning_days, updated_at = :updated_at, updated_by = :updated_by WHERE id = :id', [ 'show_card_age' => $showCardAge ? 1 : 0, 'card_age_warning_days' => $cardAgeWarningDays, 'updated_at' => $updatedAt, 'updated_by' => $updatedBy, 'id' => $id, ] ); } public function updatePosition(int $id, int $position, string $updatedAt, string $updatedBy): void { $this->database->execute( 'UPDATE board_columns SET position = :position, updated_at = :updated_at, updated_by = :updated_by WHERE id = :id', ['position' => $position, 'updated_at' => $updatedAt, 'updated_by' => $updatedBy, 'id' => $id] ); } public function deleteByBoardId(int $boardId): void { $this->database->execute('DELETE FROM board_columns WHERE board_id = :board_id', ['board_id' => $boardId]); } }