| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\librarys\shareTree\models;
- use yii\base\InvalidConfigException;
- use yii\behaviors\TimestampBehavior;
- use yii\db\ActiveRecord;
- use yii\db\Expression;
- /**
- * @property int $parent_id
- * @property int $child_id
- * @property int $nearest_parent_id
- * @property int $parent_level
- * @property int $child_level
- * @property string $created_at
- */
- abstract class AbstractTreePath extends ActiveRecord
- {
- /**
- * @inheritDoc
- */
- public static function tableName(): string
- {
- throw new InvalidConfigException('请指定用于存储父子关系的表名称');
- }
- /**
- * @inheritDoc
- */
- public static function primaryKey()
- {
- return ['parent_id', 'child_id'];
- }
- /**
- * @inheritDoc
- */
- public function behaviors(): array
- {
- return [
- [
- 'class' => TimestampBehavior::class,
- 'createdAtAttribute' => 'created_at',
- 'updatedAtAttribute' => null,
- 'value' => new Expression('NOW()'),
- ],
- ];
- }
- }
|