validator; } /** * 构建查询条件 */ protected function buildQueryConfig(Request $request, string $scene = 'index'): 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 (['dict_name','dict_code','description'] as $col) { $config['orWhere'][] = [$col, 'like', $k]; } } // ====== ====== 关联 ====== ====== $config['with']['sysDictItem'][] = 'item_label'; $config['with']['sysDictItem'][] = 'item_value'; break; case 'show': $config['where']['id'] = $p['id']; // ====== ====== 关联 ====== ====== $config['with']['sysDictItem'][] = 'item_label'; $config['with']['sysDictItem'][] = 'item_value'; break; case 'update': case 'destroy': $config['where']['id'] = $p['id']; break; case 'store': break; } return $config; } }