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