validator; } /** * 构建查询条件 */ protected function buildQueryConfig(Request $request, string $scene = 'default'): array { $p = $request->all(); $config = []; $config['model'] = $this->modelClass; switch ($scene) { case 'index': // ====== ====== 排序 ====== ====== $config['order']['id'] = 'desc'; // ====== ====== 筛选 ====== ====== // 状态 if (isset($p['status']) && in_array($p['status'], [0,1])) { $config['where']['status'] = $p['status']; } // 关键字 if (isset($p['keyword']) && $p['keyword']) { $k = '%' . $p['keyword'] . '%'; foreach (['config_key','config_value','description'] as $col) { $config['orWhere'][] = [$col, 'like', $k]; } } break; case 'show': $config['where']['id'] = $p['id']; //$config['where']['status'] = 1; break; case 'store': break; case 'update': $config['where']['id'] = $p['id']; break; case 'destroy': $config['where']['id'] = $p['id']; break; } return $config; } public function beforeServiceUpdate($data, Request $request) { Redis::del($data['config_key']); } }