Skip to content

Commit

Permalink
encode arrays to json
Browse files Browse the repository at this point in the history
  • Loading branch information
hackeresq committed Mar 26, 2022
1 parent 55888e1 commit e20900c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private function upsert(string $key, $value)
],
[
'key' => $key,
'value' => $value,
'value' => is_array($value) ? json_encode($value) : $value,
'tenant' => $this->tenant
]
);
Expand Down
12 changes: 12 additions & 0 deletions tests/SettingsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,4 +310,16 @@ public function it_can_return_default_all_settings()
$this->assertEquals('test', $settings['not_set'], json_encode($settings));

}

/** @test */
public function it_encodes_arrays_to_json()
{
$this->app['config']->set('settings.fillable', ['*']);

Settings::set(['array' => ['test', 'one', 'two']]);

$settings = json_decode(Settings::get('array'));

$this->assertIsArray($settings, json_encode($settings));
}
}

0 comments on commit e20900c

Please sign in to comment.