/** * Validate and save changes. * * @return Response */ public function patchIndex(BoardConfigRequest $request, Board $board) { $input = $request->all(); $optionGroups = $request->getBoardOptions(); foreach ($optionGroups as $optionGroup) { foreach ($optionGroup->options as $option) { $setting = BoardSetting::firstOrNew(['option_name' => $option->option_name, 'board_uri' => $board->board_uri]); $option->option_value = $input[$option->option_name]; $setting->option_value = $input[$option->option_name]; $setting->save(); } } $board->title = $input['boardBasicTitle']; $board->description = $input['boardBasicDesc']; $board->is_overboard = isset($input['boardBasicOverboard']) && !!$input['boardBasicOverboard']; $board->is_indexed = isset($input['boardBasicIndexed']) && !!$input['boardBasicIndexed']; $board->is_worksafe = isset($input['boardBasicWorksafe']) && !!$input['boardBasicWorksafe']; $board->save(); Event::fire(new BoardWasModified($board)); return $this->view(static::VIEW_CONFIG, ['board' => $board, 'groups' => $optionGroups]); }
/** * Validate and save changes. * * @return Response */ public function patchConfig(BoardConfigRequest $request, Board $board) { $input = $request->all(); $optionGroups = $request->getBoardOptions(); $settings = []; foreach ($optionGroups as &$optionGroup) { foreach ($optionGroup->options as &$option) { $setting = BoardSetting::firstOrNew(['option_name' => $option->option_name, 'board_uri' => $board->board_uri]); // Skip locked items unless we can edit them. $locking = isset($input['lock'][$option->option_name]) && !!$input['lock'][$option->option_name]; if ($setting->isLocked() && !$this->user->canEditSettingLock($board, $option)) { continue; } // Save the value. if (isset($input[$option->option_name])) { $setting->option_value = $input[$option->option_name]; } else { if ($option->format == "onoff") { $setting->option_value = false; } else { if (!$locking) { // Delete it if we have no value and aren't saving. $setting->delete(); continue; } else { $setting->option_value = null; } } } // Set our locked status. if ($locking) { $setting->is_locked = !!$input['lock'][$option->option_name]; } $setting->save(); $settings[] = $setting; } } $board->title = $input['boardBasicTitle']; $board->description = $input['boardBasicDesc']; $board->is_overboard = isset($input['boardBasicOverboard']) && !!$input['boardBasicOverboard']; $board->is_indexed = isset($input['boardBasicIndexed']) && !!$input['boardBasicIndexed']; $board->is_worksafe = isset($input['boardBasicWorksafe']) && !!$input['boardBasicWorksafe']; $board->save(); Event::fire(new BoardWasModified($board)); return $this->getConfig($board); }