/
pashko
/
siec
Обзор
Документация
Войти
/
pashko
/
siec
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
common/models/Pages.php
77 строк
2 KB
Kokorin Pavel
fix word
11 май 2020, 09:05
11 май 2020, 09:05
d5cdf0c
Код
Авторство
О чём код?
<?php namespace common\models; /** * This is the model class for table "pages". * * @property int $id * @property string $title * @property string $short_text * @property string $text * @property string $active */ class Pages extends \yii\db\ActiveRecord { function behaviors() { return [ 'seo' => [ 'class' => 'dvizh\seo\behaviors\SeoFields', ], 'toPlusCategory' => [ 'class' => 'voskobovich\manytomany\ManyToManyBehavior', 'relations' => [ 'plus_category_ids' => 'pluscategories', ], ] ]; } /** * {@inheritdoc} */ public static function tableName() { return 'pages'; } /** * {@inheritdoc} */ public function rules() { return [ [['short_text', 'text', 'active', 'code', 'menu_title', 'slug'], 'string'], [['title'], 'string', 'max' => 255], [['sort', 'in_menu'], 'integer'], [['title'], 'required'], [['plus_category_ids'], 'each', 'rule' => ['integer']], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'title' => 'Title', 'short_text' => 'Short Text', 'text' => 'Text', 'active' => 'Active', 'code' => 'Код страницы', 'in_menu' => 'Показывать в меню', 'sort' => 'Сортировка', 'menu_title' => 'Название в меню', 'slug' => 'Урл страницы', ]; } public function getPluscategories() { return $this->hasMany(PlusCategory::className(), ['id' => 'plus_category_id']) ->viaTable('{{%pages_to_plus_category}}', ['page_id' => 'id']); } }