user()->can('create', GroupSetting::class); } public function rules() { $rules['name'] = 'required'; $rules['settings'] = new ValidClientGroupSettingsRule(); return $rules; } protected function prepareForValidation() { $input = $this->all(); $group_settings = ClientSettings::defaults(); if (array_key_exists('settings', $input) && !empty($input['settings'])) { foreach ($input['settings'] as $key => $value) { $group_settings->{$key} = $value; } } $input['settings'] = $group_settings; $this->replace($input); } public function messages() { return [ 'settings' => 'settings must be a valid json structure' ]; } }