{"action":"created","issue":{"url":"https://api.github.com/repos/anlutro/laravel-settings/issues/54","repository_url":"https://api.github.com/repos/anlutro/laravel-settings","labels_url":"https://api.github.com/repos/anlutro/laravel-settings/issues/54/labels{/name}","comments_url":"https://api.github.com/repos/anlutro/laravel-settings/issues/54/comments","events_url":"https://api.github.com/repos/anlutro/laravel-settings/issues/54/events","html_url":"https://github.com/anlutro/laravel-settings/issues/54","id":157422690,"number":54,"title":"Enhancement - Flatten arrays","user":{"login":"MarcosBL","id":389801,"avatar_url":"https://avatars.githubusercontent.com/u/389801?v=3","gravatar_id":"","url":"https://api.github.com/users/MarcosBL","html_url":"https://github.com/MarcosBL","followers_url":"https://api.github.com/users/MarcosBL/followers","following_url":"https://api.github.com/users/MarcosBL/following{/other_user}","gists_url":"https://api.github.com/users/MarcosBL/gists{/gist_id}","starred_url":"https://api.github.com/users/MarcosBL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MarcosBL/subscriptions","organizations_url":"https://api.github.com/users/MarcosBL/orgs","repos_url":"https://api.github.com/users/MarcosBL/repos","events_url":"https://api.github.com/users/MarcosBL/events{/privacy}","received_events_url":"https://api.github.com/users/MarcosBL/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-05-30T02:48:51Z","updated_at":"2016-05-30T12:27:41Z","closed_at":null,"body":"In order to create an admin frontend to edit the database values, I have found problems with the nested array keys. In the end I added a helper function to flatten the array, maybe it could be nice to add it to the set of tools of the package:\r\n\r\n````php\r\nfunction flatten($array, $prefix = '') {\r\n    $result = array();\r\n    foreach($array as $key=>$value) {\r\n        if(is_array($value)) {\r\n            $result = $result + flatten($value, $prefix . $key . '.');\r\n        }\r\n        else {\r\n            $result[$prefix . $key] = $value;\r\n        }\r\n    }\r\n    return $result;\r\n}\r\n````\r\n\r\nSo now I can just:\r\n\r\n````php\r\nreturn view('admin.settings', [ 'settings' => Functions::flatten( \\Setting::all() ) ]);\r\n````\r\n\r\nAnd in the view...\r\n\r\n````php\r\n@foreach($settings as $key => $value)\r\n\t<div class='form-group'>\r\n\t\t{{ Form::label($key, ucwords(str_replace(\".\", \" \", $key)), ['class' => 'col-sm-2 control-label']) }}\r\n\t\t<div class=\"col-sm-10\">\r\n\t\t\t{{ Form::textarea($key, $value, ['class'=>'form-control', 'autofocus' => '']) }}\r\n\t\t</div>\r\n\t</div>\r\n@endforeach\r\n````\r\n\r\nSo, for this kind of data\r\n\r\n![0](https://cloud.githubusercontent.com/assets/389801/15638705/29f8b146-2623-11e6-978a-fe78dc381e70.png)\r\n\r\n\r\nIt gives me a nice:\r\n\r\n![flatten](https://cloud.githubusercontent.com/assets/389801/15638695/fbc579b2-2622-11e6-80eb-9c71f5a60b93.png)\r\n\r\nJust my 2 cents"},"comment":{"url":"https://api.github.com/repos/anlutro/laravel-settings/issues/comments/222481898","html_url":"https://github.com/anlutro/laravel-settings/issues/54#issuecomment-222481898","issue_url":"https://api.github.com/repos/anlutro/laravel-settings/issues/54","id":222481898,"user":{"login":"anlutro","id":163093,"avatar_url":"https://avatars.githubusercontent.com/u/163093?v=3","gravatar_id":"","url":"https://api.github.com/users/anlutro","html_url":"https://github.com/anlutro","followers_url":"https://api.github.com/users/anlutro/followers","following_url":"https://api.github.com/users/anlutro/following{/other_user}","gists_url":"https://api.github.com/users/anlutro/gists{/gist_id}","starred_url":"https://api.github.com/users/anlutro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anlutro/subscriptions","organizations_url":"https://api.github.com/users/anlutro/orgs","repos_url":"https://api.github.com/users/anlutro/repos","events_url":"https://api.github.com/users/anlutro/events{/privacy}","received_events_url":"https://api.github.com/users/anlutro/received_events","type":"User","site_admin":false},"created_at":"2016-05-30T12:27:41Z","updated_at":"2016-05-30T12:27:41Z","body":"Would you like to try and make a pull request for the feature? I think it should just be a matter of adding a new `public function getRawData` (or something similar) to the `DatabaseSettingStore` class and that should make it available as `Setting::getRawData` if you use the database store. It should be fairly easy to write if you look at the existing `read` method for reference."}}
{"actor":{"display_login":"anlutro"}}