diff --git a/src/Resources/Sheet.php b/src/Resources/Sheet.php index fd81b5b..57eb76a 100644 --- a/src/Resources/Sheet.php +++ b/src/Resources/Sheet.php @@ -32,7 +32,9 @@ public function dropAndReplace(array $rows) { $this->dropAllRows(); - $this->addRows($rows); + foreach (collect($rows)->chunk(500) as $chunk) { + $this->addRows($chunk->toArray()); + } } public function dropAllRows() @@ -186,6 +188,7 @@ public function addRows(array $rows): object 'cells' => $this->generateRowCells($cells) ]; }) + ->values() ->toArray() ); } @@ -272,10 +275,10 @@ public function replaceRows(array $cells, string $primaryColumnName) * Adds a row to the sheet * * @param array $cells - * @return array + * @return object * @throws Exception */ - public function createRow(array $cells): array + public function createRow(array $cells): object { return $this->insertRows([ 'toBottom' => true, diff --git a/src/SmartsheetClient.php b/src/SmartsheetClient.php index bebef98..ccdead7 100644 --- a/src/SmartsheetClient.php +++ b/src/SmartsheetClient.php @@ -102,7 +102,7 @@ public function getFolder(string $folderId): Folder */ public function getWorkspace(string $workspaceId): Workspace { - return new Workspace($this, $this->get("workspaces/$workspaceId")); + return new Workspace($this, (array) $this->get("workspaces/$workspaceId")); } /**