/
pashko
/
siec
Обзор
Документация
Войти
/
pashko
/
siec
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
common/models/Service.php
175 строк
6 KB
Kokorin Pavel
service block on index page
10 май 2020, 21:11
10 май 2020, 21:11
885a726
Код
Авторство
О чём код?
<?php namespace common\models; /** * This is the model class for table "service". * * @property int $id * @property string $name * @property string $short_text * @property string $text * @property string $slug * @property int $banner_id * @property string $form_title * @property string $form_subtitle * @property int $sort * @property string $active */ class Service extends \yii\db\ActiveRecord { /** * @return array */ function behaviors() { return [ 'images' => [ 'class' => 'dvizh\gallery\behaviors\AttachImages', 'mode' => 'gallery', ], 'slug' => [ 'class' => 'Zelenin\yii\behaviors\Slug', ], 'toPlusCategory' => [ 'class' => 'voskobovich\manytomany\ManyToManyBehavior', 'relations' => [ 'plus_category_ids' => 'pluscategories', ], ], /*'toPluses' => [ 'class' => 'voskobovich\manytomany\ManyToManyBehavior', 'relations' => [ 'pluses_ids' => 'pluses', ], ],*/ 'toSupply' => [ 'class' => 'voskobovich\manytomany\ManyToManyBehavior', 'relations' => [ 'case_ids' => 'cases', ], ], 'toFaq' => [ 'class' => 'voskobovich\manytomany\ManyToManyBehavior', 'relations' => [ 'faq_ids' => 'faqs', ], ], 'toBannerBg' => [ 'class' => 'voskobovich\manytomany\ManyToManyBehavior', 'relations' => [ 'banner_bg_ids' => 'bannerBgs', ], ], 'seo' => [ 'class' => 'dvizh\seo\behaviors\SeoFields', ] ]; } /** * {@inheritdoc} */ public static function tableName() { return 'service'; } /** * {@inheritdoc} */ public function rules() { return [ [['name'], 'required'], [['text', 'active', 'icon', 'short_text', /*'menu_title',*/ 'small_name'], 'string'], [['banner_id', 'sort', /*'form_type_id', 'banner_type', 'hide_cases'*/], 'integer'], [['name', 'slug', 'form_title', 'form_subtitle', 'review_block_title', 'case_block_title', 'little_text'/*, 'picker_title'*/], 'string', 'max' => 255], [['plus_category_ids', 'case_ids', 'faq_ids'/*, 'pluses_ids', 'banner_bg_ids'*/], 'each', 'rule' => ['integer']], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'name' => 'Name', 'small_name' => 'Короткое название для карточки', 'short_text' => 'Short Text', 'text' => 'Text', 'slug' => 'Slug', 'banner_id' => 'Баннер', 'form_title' => 'Form Title', 'form_subtitle' => 'Form Subtitle', 'sort' => 'Sort', 'active' => 'Active', 'icon' => 'Icon', 'review_block_title' => 'Заголовок блока отзывов', 'case_block_title' => 'Заголовок блока кейсов', 'little_text' => 'Текст на главной', 'form_type_id' => 'Тип формы баннера', 'banner_type' => 'Тип баннера', 'hide_cases' => 'Скрывать кейсы', 'picker_title' => 'Заголовок блока со статьями', 'menu_title' => 'Название в меню', ]; } /** * @return \yii\db\ActiveQuery */ public function getPluscategories() { return $this->hasMany(PlusCategory::className(), ['id' => 'plus_category_id']) ->viaTable('{{%service_to_plus_category}}', ['service_id' => 'id']); } /** * @return \yii\db\ActiveQuery */ public function getCases() { return $this->hasMany(Supply::className(), ['id' => 'case_id']) ->viaTable('{{%service_to_case}}', ['service_id' => 'id']); } /** * @return \yii\db\ActiveQuery * @throws \yii\base\InvalidConfigException */ public function getPluses() { return $this->hasMany(Pluses::className(), ['id' => 'pluses_id']) ->viaTable('{{%service_to_pluses}}', ['service_id' => 'id']); } /** * @return \yii\db\ActiveQuery * @throws \yii\base\InvalidConfigException */ public function getFaqs() { return $this->hasMany(Supply::className(), ['id' => 'faq_id']) ->viaTable('{{%service_to_faq}}', ['service_id' => 'id']); } /** * @return \yii\db\ActiveQuery */ public function getBlogs() { return $this->hasMany(Blog::className(), ['id' => 'blog_id']) ->viaTable('{{%blog_to_service}}', ['service_id' => 'id']); } /** * @return \yii\db\ActiveQuery */ public function getBannerBgs() { return $this->hasMany(BannerBg::className(), ['id' => 'banner_bg_id']) ->viaTable('{{%banner_bg_to_service}}', ['service_id' => 'id']); } }