Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Apr 4, 2022
1 parent 156773c commit 05846e7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Illuminate/Database/Eloquent/Casts/AsArrayObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ public static function castUsing(array $arguments)
{
public function get($model, $key, $value, $attributes)
{
if (! isset($attributes[$key])) {
return;
}

$data = json_decode($attributes[$key], true);

return is_array($data) ? new ArrayObject($data) : null;
Expand Down
4 changes: 4 additions & 0 deletions src/Illuminate/Database/Eloquent/Casts/AsCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ public static function castUsing(array $arguments)
{
public function get($model, $key, $value, $attributes)
{
if (! isset($attributes[$key])) {
return;
}

$data = json_decode($attributes[$key], true);

return is_array($data) ? new Collection($data) : null;
Expand Down

0 comments on commit 05846e7

Please sign in to comment.