[ '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() { $this->uuid = Utils::genUUID(); } }