request->param('username', ''); // $_op = $this->whereLike('username', "{$username}%"); // return parent::parentLists($_op); //通用逻辑 return parent::parentLists(); } /** * 读取后 * @param Model $model * @return bool|void */ public static function onAfterRead(Model $model) { //读取数据前格式化数据 if (in_array(request()->action(), ['edit', 'delete', 'status'])) { return true; } //业务逻辑 } /** * 新增或修改前 * @param Model $model * @return mixed|void */ public static function onBeforeWrite(Model $model) { parent::onBeforeWrite($model); //写入数据前格式化数据 if (!in_array(request()->action(), ['add', 'edit'])) { return true; } //业务逻辑 // code... //以下参数禁止新增或者修改 $model->offsetUnset('ip'); } }