| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- namespace common\models;
- use Yii;
- /**
- * This is the model class for table "{{%ARTICLE_CATEGORY}}".
- *
- * @property string $ID
- * @property string $CATE_NAME 分类名
- * @property int $SORT
- * @property int $STATUS 状态
- * @property int $CREATED_AT 创建时间
- */
- class ArticleCategory extends \common\components\ActiveRecord
- {
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return '{{%ARTICLE_CATEGORY}}';
- }
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['CATE_NAME', 'CREATED_AT'], 'required'],
- [['SORT', 'STATUS', 'CREATED_AT'], 'integer'],
- [['ID'], 'string', 'max' => 32],
- [['CATE_NAME'], 'string', 'max' => 20],
- [['CATE_NAME'], 'unique'],
- [['ID'], 'unique'],
- ];
- }
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'ID' => 'ID',
- 'CATE_NAME' => Yii::t('app', 'category'),
- 'STATUS' => Yii::t('app', 'status'),
- 'SORT' => Yii::t('app', 'sort'),
- 'CREATED_AT' => Yii::t('app', 'createAt'),
- ];
- }
- /**
- * 获取全部分类
- * @return array|\yii\db\ActiveRecord[]
- */
- public static function getAllCategory(){
- return ArticleCategory::find()->where('STATUS=1')->indexBy('ID')->orderBy('SORT ASC')->asArray()->all();
- }
- }
|