123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace app\models\base;
- use Yii;
- /**
- * This is the model class for table "top_slider".
- *
- * @property int $id
- * @property int|null $post_id
- * @property string|null $published_from
- * @property string|null $published_to
- * @property int|null $is_active
- * @property News $post
- */
- class TopSlider extends \yii\db\ActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return 'top_slider';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['post_id', 'is_active'], 'integer'],
- [['published_from', 'published_to'], 'safe'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'post_id' => 'Post ID',
- 'published_from' => 'В слайдере с',
- 'published_to' => 'В слайдере по',
- 'is_active' => 'активна',
- ];
- }
- public function getPost()
- {
- return $this->hasOne(News::class,['id'=>'post_id']);
- }
- /**
- * {@inheritdoc}
- * @return TopSliderQuery the active query used by this AR class.
- */
- public static function find()
- {
- return new TopSliderQuery(get_called_class());
- }
- public function beforeSave($insert)
- {
- $this->published_from = date("Y-m-d H:i:s",strtotime($this->published_from));
- $this->published_to = date("Y-m-d H:i:s",strtotime($this->published_to));
- return parent::beforeSave($insert);
- }
- }
|