Skip to content

Commit

Permalink
Hotfix support for files
Browse files Browse the repository at this point in the history
  • Loading branch information
ajmariduena committed Mar 3, 2019
1 parent 411aace commit cad0a10
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 18 deletions.
23 changes: 11 additions & 12 deletions config/settings.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

return [

/*
|--------------------------------------------------------------------------
| Settings Path
Expand Down Expand Up @@ -29,6 +28,17 @@

'navigation' => 'Settings',

/*
|--------------------------------------------------------------------------
| Settings Disk
|--------------------------------------------------------------------------
|
| Specified disk for storing settings files.
|
*/

'disk' => 'public',

/*
|--------------------------------------------------------------------------
| Settings
Expand All @@ -45,13 +55,10 @@
*/

'panels' => [

[

'name' => 'Settings',

'settings' => [

[
'key' => 'facebook_url',
'name' => 'Facebook',
Expand All @@ -73,17 +80,13 @@
'url' => '/documentation#twitter_url',
],
],

],

],

[

'name' => 'Features',

'settings' => [

[
'key' => 'new_feature',
'name' => 'New Feature',
Expand All @@ -94,11 +97,7 @@
'url' => '/documentation#new_feature',
],
],

],

],

],

];
2 changes: 1 addition & 1 deletion dist/js/tool.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions resources/js/components/SettingsTool.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<file-setting
v-if="setting.type == 'file'"
:name="setting.name"
:accept="setting.accept"
:description="setting.description || ''"
:link="setting.link || {}"
:setting="{ key: setting.key, value: settings[setting.key] }"
Expand Down
6 changes: 4 additions & 2 deletions resources/js/components/partials/File.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
<input
type="file"
@input="input"
:accept="accept"
class="form-file-input"
id="image"
:id="setting.key"
/>
<label for="image" class="form-file-btn btn btn-default btn-primary">
<label :for="setting.key" class="form-file-btn btn btn-default btn-primary">
{{ __('Choose File') }}
</label>

Expand All @@ -38,6 +39,7 @@ export default {
name: String,
setting: Object,
description: String,
accept: String,
link: Object
},
Expand Down
22 changes: 19 additions & 3 deletions src/Http/Controllers/SettingsToolController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,29 @@ public function write(Request $request)

$settings->put($setting, Storage::url($filePath));
} else {
if ($value === 'null') {
$value = null;
}
$value = $this->castValue($value);
$settings->put($setting, $value);
}
}

return response($settings->all(), 202);
}

private function castValue($value)
{
switch ($value) {
case 'null':
return null;
break;
case 'true':
return true;
break;
case 'false':
return false;
break;
default:
return $value;
break;
}
}
}

0 comments on commit cad0a10

Please sign in to comment.