Skip to content

Commit

Permalink
Fix SettingsController saving boolean value as 'on'
Browse files Browse the repository at this point in the history
  • Loading branch information
nkevins committed Sep 4, 2018
1 parent c95fe3c commit f46e509
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions app/Http/Controllers/Admin/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public function update(Request $request)
continue;
}

if ($setting->type == 'bool' || $setting->type == 'boolean') {
$value = get_truth_state($value);
}

Log::info('Updating "'.$setting->id.'" from "'.$setting->value.'" to "'.$value.'"');
$setting->value = $value;
$setting->save();
Expand Down
2 changes: 1 addition & 1 deletion app/Repositories/SettingRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function retrieve($key)
case 'bool':
case 'boolean':
$value = $setting->value;
return $value === 'true' || $value === '1' || $value === 1 || $value === 'on';
return $value === 'true' || $value === '1' || $value === 1;
case 'date':
return Carbon::parse($setting->value);
case 'int':
Expand Down
2 changes: 1 addition & 1 deletion app/Services/UserService.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function __construct(
public function createPilot(User $user, array $groups = null)
{
// Determine if we want to auto accept
if (get_truth_state(setting('pilots.auto_accept', false)) === true) {
if (setting('pilots.auto_accept') === true) {
$user->state = UserState::ACTIVE;
} else {
$user->state = UserState::PENDING;
Expand Down

0 comments on commit f46e509

Please sign in to comment.