123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- namespace app\models;
- use app\modules\admin\models\Admin;
- use Yii;
- /**
- * This is the model class for table "{{%announce}}".
- *
- * @property int $id ID
- * @property string $title 标题
- * @property string $content 内容
- * @property int $start_time 开始显示时间
- * @property int $end_time 停止显示时间
- * @property int $admin_id 发布人
- * @property int $create_time 添加时间
- * @property int $hits 点击量
- * @property int $disabled 0:启用 1:禁用
- */
- class Announce extends \app\common\models\EActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%announce}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['title', 'content', 'start_time', 'end_time', 'admin_id'], 'required'],
- [['content'], 'string'],
- [[ 'admin_id', 'create_time', 'hits', 'disabled'], 'integer'],
- [['title'], 'string', 'max' => 100],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => Yii::t('attr','announce.id'),
- 'title' => Yii::t('attr','announce.title'),
- 'content' => Yii::t('attr','announce.content'),
- 'start_time' => Yii::t('attr','announce.start_time'),
- 'end_time' => Yii::t('attr','announce.end_time'),
- 'admin_id' => Yii::t('attr','announce.admin_id'),
- 'create_time' => Yii::t('attr','announce.create_time'),
- 'hits' => Yii::t('attr','announce.hits'),
- 'disabled' => Yii::t('attr','announce.disabled'),
- ];
- }
- public function getUsername()
- {
- if($this->admin_id)
- {
- $admin = Admin::findOne($this->admin_id);
- return $admin->real_name;
- }
- else
- {
- return '管理员';
- }
- }
- }
|