addBehavior( new SoftDelete([ 'field' => 'deleted', 'value' => 1, ]) ); } public function beforeCreate() { $this->create_time = time(); } public function beforeUpdate() { $this->update_time = time(); } public function afterCreate() { $cache = new MaxAnswerIdCache(); $cache->rebuild(); } public static function publishTypes() { return [ self::PUBLISH_PENDING => '审核中', self::PUBLISH_APPROVED => '已发布', self::PUBLISH_REJECTED => '未通过', ]; } public static function sortTypes() { return [ 'latest' => '最新', 'popular' => '最热', ]; } }