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['channel']) && $p['channel']) { $config['where']['channel'] = $p['channel']; } // 国家 if (isset($p['country']) && $p['country']) { $config['where']['country'] = $p['country']; } // 时间 if (isset($p['time']) && $p['time']) { $time = explode(' - ', $p['time']); $config['where']['created_at'] = [ 'between', [strtotime($time[0]), strtotime($time[1])] ]; } // 状态 if (isset($p['status']) && $p['status']) { $config['where']['status'] = $p['status']; } // 关键字 if (isset($p['keyword']) && $p['keyword']) { $k = '%' . $p['keyword'] . '%'; foreach (['order_no','email','tel','whatsapp','contacts'] as $col) { $config['orWhere'][] = [$col, 'like', $k]; } } // 关联 $config['with']['country'][] = 'cn_addr'; $config['with']['enter'][] = 'name'; $config['with']['recipient'][] = 'name'; $config['with']['channel'][] = 'name'; break; case 'show': $config['where']['id'] = $p['id']; break; case 'store': break; case 'update': $config['where']['id'] = $p['id']; break; case 'destroy': $config['where']['id'] = $p['id']; break; } return $config; } public function beforeServiceStore($data, Request $request) { $data['order_no'] = orderNum(); $data['enter_user_id'] = $request->user->uid; $data['recipient'] = 0; $data['email'] = trim($data["email"]); $data['tel'] = trim($data['tel']); $data['whatsapp'] = trim($data['whatsapp']); return $data; } // public function afterServiceList($data) // { // var_dump($data); // return $data; // } }