Skip to content

Commit

Permalink
Merge pull request #273 from nkevins/fix_repo_saving
Browse files Browse the repository at this point in the history
Fix SettingsController saving boolean value as 'on'
  • Loading branch information
nabeelio authored Sep 4, 2018
2 parents 24fb558 + f46e509 commit ec873f2
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 ec873f2

Please sign in to comment.