123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- namespace app\models\base;
- use Yii;
- /**
- * This is the model class for table "gallery".
- *
- * @property int $id
- * @property string|null $name
- * @property string|null $description
- * @property string|null $created_at
- * @property int|null $post_id
- *
- * @property GalleryItem[] $galleryItems
- * @property News $post
- */
- class Gallery extends \yii\db\ActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return 'gallery';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['created_at'], 'safe'],
- [['post_id'], 'integer'],
- [['name', 'description'], 'string', 'max' => 255],
- [['post_id'], 'exist', 'skipOnError' => true, 'targetClass' => News::class, 'targetAttribute' => ['post_id' => 'id']],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'name' => 'Name',
- 'description' => 'Description',
- 'created_at' => 'Created At',
- 'post_id' => 'Post ID',
- ];
- }
- /**
- * Gets query for [[GalleryItems]].
- *
- * @return \yii\db\ActiveQuery
- */
- public function getGalleryItems()
- {
- return $this->hasMany(GalleryItem::class, ['gallery_id' => 'id']);
- }
- /**
- * Gets query for [[Post]].
- *
- * @return \yii\db\ActiveQuery
- */
- public function getPost()
- {
- return $this->hasOne(News::class, ['id' => 'post_id']);
- }
- }
|