Skip to content

Commit

Permalink
Encode collection
Browse files Browse the repository at this point in the history
  • Loading branch information
mauro-moreno committed Jul 21, 2018
1 parent 369016a commit 2aae156
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -652,8 +652,9 @@ protected function hasCast($key)
*/
protected function isJsonCastable($key)
{
$castables = ['array', 'json', 'object', 'collection'];
return $this->hasCast($key) &&
in_array($this->getCastType($key), ['array', 'json', 'object'], true);
in_array($this->getCastType($key), $castables, true);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public function testCasts()
$model->object_data = ['foo' => 'bar'];
$model->active = 'true';
$model->default = 'bar';
$model->collection_data = json_encode([['foo' => 'bar', 'baz' => 'bat']]);
$model->collection_data = [['foo' => 'bar', 'baz' => 'bat']];

$this->assertTrue(is_float($model->score));
$this->assertTrue(is_array($model->data));
Expand Down

0 comments on commit 2aae156

Please sign in to comment.