[ 'class' => TimestampBehavior::className(), 'createdAtAttribute' => 'created_at', 'updatedAtAttribute' => 'updated_at', ] ]; } /* @inheritdoc */ public function init() { parent::init(); $this->attachEvents(); } /* @inheritdoc */ public function attachEvents() { $this->on(static::EVENT_BEFORE_INSERT, [$this, 'onBeforeInsert']); } /** * 记录插入前的回调处理 */ public function onBeforeInsert() { $uuid = Utils::genUUID(); $this->uuid = $uuid; $this->short_uuid = substr(md5($uuid), 8,16); } }