request->param('name', ''); $_op = $this->where('site_id', SITE_ID); //没有默认where查询 这个一定要 否则获取不到下面的getOptions查询条件值 if ($name) { $_op->whereLike('name', "%{$name}%"); } $_op->order('create_time DESC'); return parent::parentLists($_op); } /** * 读取后 * @param Model $model * @return bool|void */ public static function onAfterRead(Model $model) { if (!in_array(request()->action(), ['read','dataRead'])) { return; } //成时间戳转化时间字符串 $model->setAttr('end_time', date('Y-m-d H:i:s',$model->getAttr('end_time'))); $model->setAttr('start_time', date('Y-m-d H:i:s',$model->getAttr('start_time'))); } /** * 新增前 * @param Model $model * @return mixed|void */ public static function onBeforeInsert(Model $model) { // //时间字符串转化成时间戳 } /** * 新增或修改前 * @param Model $model * @return mixed|void */ public static function onBeforeWrite(Model $model) { if (!in_array(request()->action(), ['add', 'edit','dataEdit','dataAdd'])) { return; } //时间字符串转化成时间戳 $model->setAttr('end_time', strtotime($model->getAttr('end_time'))); $model->setAttr('start_time', strtotime($model->getAttr('start_time'))); } }