123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace app\models;
- use app\models\base\NewsTopic;
- use Yii;
- /**
- * This is the model class for table "topic_images".
- *
- * @property int $id
- * @property int|null $topic_id
- * @property string|null $uploaded_at
- * @property string|null $alt
- * @property string|null $ext
- * @property NewsTopic $topic
- */
- class TopicImages extends \yii\db\ActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return 'topic_images';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['topic_id'], 'integer'],
- [['uploaded_at'], 'safe'],
- [['alt','ext'], 'string'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'topic_id' => 'Topic ID',
- 'uploaded_at' => 'Uploaded At',
- 'alt' => 'Alt',
- ];
- }
- public function getTopic(){
- return $this->hasOne(NewsTopic::class,["id"=>"topic_id"]);
- }
- public function getUrl(){
- return "/topic-images/{$this->topic_id}/{$this->id}.{$this->ext}";
- }
- }
|