request->param('username', ''); $sex = $this->request->param('sex', '', 'intval'); $truename = $this->request->param('truename', ''); $_op = $this->where('site_id', SITE_ID); //没有默认where查询 这个一定要 否则获取不到下面的getOptions查询条件值 if ($username) { $_op->whereLike('username', "%{$username}%"); } $data = parent::parentLists($_op); //获取栏目类型 $_column_type = config('dictionary.sqlfields.column_type'); $_model = Db::name('model')->column('*', 'id'); $data_tmp = $data['data']; array_walk($data_tmp, function (&$v) use ($_model, $_column_type) { $v['model_name'] = $_model[$v['model_id']]['name']; $v['column_type_name'] = $_column_type[$v['type']]; }); $data['data'] = $data_tmp; // $data = tree($data); return $data; } /** * 读取后 * @param Model $model * @return bool|void */ public static function onAfterRead(Model $model) { $model->setAttr('open', true); } /** * 新增前 * @param Model $model * @return mixed|void */ public static function onBeforeInsert(Model $model) { //code } /** * 新增或修改前 * @param Model $model * @return mixed|void */ public static function onBeforeWrite(Model $model) { } public static function onAfterDelete(Model $model) { //删除父级栏目下所有子栏目 self::destroy(function ($query) use ($model) { $query->where('child_list', 'like', $model->getAttr('child_list') . '%'); }); parent::onAfterDelete($model); } }