Commit 9877397e authored by Shakarim Sapa's avatar Shakarim Sapa

- Поле template_id добавлено в модель

parent 2bd62ee2
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace common\modules\content\models; namespace common\modules\content\models;
use common\modules\messageTemplate\models\MessageTemplate;
use Yii; use Yii;
use yii\behaviors\TimestampBehavior; use yii\behaviors\TimestampBehavior;
use frontend\modules\sitemap\behaviors\SitemapBehavior; use frontend\modules\sitemap\behaviors\SitemapBehavior;
...@@ -22,6 +23,7 @@ use common\models\MetaTags; ...@@ -22,6 +23,7 @@ use common\models\MetaTags;
* @property string $title * @property string $title
* @property string $text * @property string $text
* @property integer $active * @property integer $active
* @property integer $template_id
* @property integer $created_at * @property integer $created_at
* @property integer $updated_at * @property integer $updated_at
* *
...@@ -115,7 +117,7 @@ class CoContent extends \common\components\ActiveRecordModel ...@@ -115,7 +117,7 @@ class CoContent extends \common\components\ActiveRecordModel
public function rules() public function rules()
{ {
return [ return [
[['active', 'type'], 'integer'], [['active', 'type', 'template_id'], 'integer'],
[['file'], 'file', 'skipOnEmpty' => true, 'extensions' => 'png, jpg, jpeg, gif'], [['file'], 'file', 'skipOnEmpty' => true, 'extensions' => 'png, jpg, jpeg, gif'],
[['url', 'type', 'priority'], 'required'], [['url', 'type', 'priority'], 'required'],
[['url'], 'string', 'max' => 250], [['url'], 'string', 'max' => 250],
...@@ -142,6 +144,7 @@ class CoContent extends \common\components\ActiveRecordModel ...@@ -142,6 +144,7 @@ class CoContent extends \common\components\ActiveRecordModel
'active' => Yii::t('content', 'Active'), 'active' => Yii::t('content', 'Active'),
'created_at' => Yii::t('content', 'Created At'), 'created_at' => Yii::t('content', 'Created At'),
'updated_at' => Yii::t('content', 'Updated At'), 'updated_at' => Yii::t('content', 'Updated At'),
'template_id' => 'Шаблон для рассылки'
]; ];
} }
...@@ -181,6 +184,13 @@ class CoContent extends \common\components\ActiveRecordModel ...@@ -181,6 +184,13 @@ class CoContent extends \common\components\ActiveRecordModel
return $this->hasOne(CoCategory::className(), ['id' => 'category_id']); return $this->hasOne(CoCategory::className(), ['id' => 'category_id']);
} }
/**
* @return \yii\db\ActiveQuery
*/
public function getTemplate() {
return $this->hasOne(MessageTemplate::className(), ['id' => 'template_id']);
}
public function getLang($lang_id = null) public function getLang($lang_id = null)
{ {
$lang_id = ($lang_id === null)? Languages::getCurrent()->id: $lang_id; $lang_id = ($lang_id === null)? Languages::getCurrent()->id: $lang_id;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment