Skip to content

Commit

Permalink
Fixes collection as json
Browse files Browse the repository at this point in the history
  • Loading branch information
papac committed Aug 21, 2023
1 parent 85de991 commit ff05d71
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions src/Database/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,26 +73,14 @@ public function dropAll(): void
*/
public function __toString(): string
{
$data = [];

foreach ($this->toArray() as $model) {
$data[] = $model->toArray();
}

return json_encode($data);
return json_encode($this->all());
}

/**
* @inheritdoc
*/
public function jsonSerialize(): array
{
$data = [];

foreach ($this->toArray() as $model) {
$data[] = $model->toArray();
}

return $data;
return $this->all();
}
}

0 comments on commit ff05d71

Please sign in to comment.