0], ['placeholder', 'default', 'value' => $defaults['placeholder']], ['searchBtnColor', 'default', 'value' => $defaults['searchBtnColor']], ['searchFontColor', 'default', 'value' => $defaults['searchFontColor']], ['customerServiceEnabled', 'default', 'value' => 0], ['placeholder', 'required', 'message' => '请输入搜索占位文案'], ['placeholder', 'trim'], ['placeholder', 'string', 'max' => 50, 'tooLong' => '搜索占位文案不能超过50字'], [['searchBtnColor', 'searchFontColor'], 'string'], [['enabled', 'customerServiceEnabled'], 'filter', 'filter' => function ($value) { return !empty($value) ? 1 : 0; }], ]; } public function attributeLabels() { return [ 'enabled' => '开关', 'placeholder' => '搜索占位文案', 'searchBtnColor' => '搜索按钮颜色', 'searchFontColor' => '搜索字体颜色', 'customerServiceEnabled' => '客服开关', ]; } /** * 写入 Redis 的样式字段(不含模块开关) * @return array */ public function getPayload() { return [ 'placeholder' => trim(strval($this->placeholder)), 'searchBtnColor' => strval($this->searchBtnColor), 'searchFontColor' => strval($this->searchFontColor), 'customerServiceEnabled' => !empty($this->customerServiceEnabled) ? 1 : 0, ]; } /** * @return int */ public function getEnabled() { return !empty($this->enabled) ? 1 : 0; } }