WebflowApiCollection.php 750 B

1234567891011121314151617181920212223242526
  1. <?php
  2. namespace App\Http\WebflowApi;
  3. class WebflowApiCollection extends AbstractWebflowApiField {
  4. protected function getLoadScope(): string
  5. {
  6. return sprintf('collections/%s', $this->data['_id']);
  7. }
  8. public function getItems(): ?WebflowApiCollectionItems {
  9. return $this->loadCollection(
  10. sprintf('collections/%s/items', $this->data['_id']),
  11. WebflowApiCollectionItems::class
  12. );
  13. }
  14. public function createItem(array $data): WebflowApiCollectionItem {
  15. $resp = $this->getClient()->post(
  16. $this->getLoadScope() . DIRECTORY_SEPARATOR . "items",
  17. $data
  18. );
  19. return new WebflowApiCollectionItem($this->getClient(), $resp->toArray());
  20. }
  21. }