safer casting for boolean values

This commit is contained in:
Nabeel Shahzad 2018-01-19 16:02:49 -05:00
parent 7c70bb0971
commit 36c904d98d

View File

@ -42,7 +42,14 @@ class SettingRepository extends BaseRepository implements CacheableInterface
switch($setting->type) {
case 'bool':
case 'boolean':
return (bool) $setting->value;
$value = $setting->value;
if($value === 'true' || $value === '1') {
$value = true;
} elseif($value === 'false' || $value === '0') {
$value = false;
}
return (bool) $value;
break;
case 'date':
return Carbon::parse($setting->value);