Skip to content

Commit

Permalink
fix issue converting table object to array
Browse files Browse the repository at this point in the history
when a table object doesn't have any column it throw an error because columns doesn't not exists (it's not an array)
  • Loading branch information
wellingguzman committed Apr 1, 2018
1 parent 87bb231 commit eaa4106
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions api/core/Directus/Database/Object/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Table implements \ArrayAccess, Arrayable, \JsonSerializable
/**
* @var Column[]
*/
protected $columns;
protected $columns = [];

/**
* Column that represents the table main value
Expand Down Expand Up @@ -1100,8 +1100,11 @@ public function toArray()
{
$array = $this->propertyArray();
$columns = [];
foreach($array['columns'] as $column) {
$columns[] = $column->toArray();

if (isset($array['columns'])) {
foreach($array['columns'] as $column) {
$columns[] = $column->toArray();
}
}

$array['columns'] = $columns;
Expand Down

0 comments on commit eaa4106

Please sign in to comment.