input('search', "")); $start = $end = null; $fieldSearchable = $this->repository->getFieldsSearchable(); foreach ($search as $value) { if (!empty($value)) { list($one, $tow) = explode(":", $value); if (!empty($fieldSearchable[$one])) { if ($fieldSearchable[$one] == 'like') $tow = "%{$tow}%"; $where[] = [$one, $fieldSearchable[$one], $tow]; } elseif ($one == 'start') { $start = $tow . " 00:00:00"; } elseif ($one == 'end') { $end = $tow . " 23:59:59"; } else { continue; } } } return function ($query) use ($where, $start, $end) { if ($start) $where[] = ['created_at', '>=', $start]; if ($end) $where[] = ['created_at', '<=', $end]; if ($where) { $query->where($where); } }; } /** * 数据更新 */ protected function _indexPost($data) { foreach ($data as $value){ $value->{'level_name'}=Level::where('id',$value->{'level_id'})->value('name')?:'L0'; } return $data; } /** * 修改数据组建 * @param $id * @return array */ function _editGet($id) { $model = $this->repository->find($id); $level_list = $this->getLevelList($model->{'level_id'}); return ['model' => $model, 'levelList' => json_encode($level_list, JSON_UNESCAPED_SLASHES)]; } function _updatePost($request, $id) { $level_id = request()->input('level_id', '0'); return Member::where('id', $id)->update(['level_id' => $level_id,'is_auto' => 0]); } /** * 获取层级菜单组件 * @return array */ private function getLevelList($level = '0') { $option = [ 'checked' => $level . '', 'attr' => [ [ 'value' => '0', 'label' => "L0", 'disabled' => false, 'notice' => '*' ], ] ]; $levels=Level::select(['id','name'])->get(); foreach ($levels as $level){ $option['attr'][]=[ 'value' => $level->{'id'}.'', 'label' => $level->{'name'}, 'disabled' => false, 'notice' => '*' ]; } return $option; } function selectAll() { return view('admins.members.all'); } function getUserIds(){ $user_ids=Member::where('is_del',0)->pluck('id')->toArray(); return $this->success('获取数据成功','',$user_ids); } }