| Current Path : /var/www/html/dosm/backend/models/frontendtheme/ |
| Current File : /var/www/html/dosm/backend/models/frontendtheme/FrontendTheme.php |
<?php
namespace backend\models\frontendtheme;
use backend\models\frontendfooter\FrontendFooter;
use backend\models\frontendheader\FrontendHeader;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\behaviors\BlameableBehavior;
use yii\db\Expression;
use yii\db\ActiveRecord;
use asinfotrack\yii2\audittrail\behaviors\AuditTrailBehavior;
/**
* This is the model class for table "frontend_theme".
*
* @property int $theme_id
* @property string $title
* @property string $description
* @property int $header_id
* @property int $footer_id
* @property string|null $theme_setup
* @property string|null $theme_css
* @property string|null $theme_js
* @property string|null $created_at
* @property string|null $updated_at
*/
class FrontendTheme extends \yii\db\ActiveRecord {
public $header_description, $footer_description;
/**
* {@inheritdoc}
*/
public static function tableName() {
return 'frontend_theme';
}
public function behaviors() {
return [
'audittrail' => [
'class' => AuditTrailBehavior::className(),
// some of the optional configurations
'ignoredAttributes' => ['created_at', 'updated_at'],
'consoleUserId' => 1,
'attributeOutput' => [
'desktop_id' => function ($value) {
$model = Desktop::findOne($value);
return sprintf('%s %s', $model->manufacturer, $model->device_name);
},
'last_checked' => 'datetime',
],
],
];
}
/**
* {@inheritdoc}
*/
public function rules() {
return [
[['header_id', 'footer_id'], 'integer'],
[['theme_setup', 'theme_css', 'theme_js'], 'string'],
[['created_at', 'updated_at'], 'safe'],
[['title'], 'string', 'max' => 250],
[['description'], 'string', 'max' => 2500],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels() {
return [
'theme_id' => Yii::t('app', 'Theme ID'),
'title' => Yii::t('app', 'Title'),
'description' => Yii::t('app', 'Description'),
'header_id' => Yii::t('app', 'Header ID'),
'footer_id' => Yii::t('app', 'Footer ID'),
'theme_setup' => Yii::t('app', 'Theme Setup'),
'created_at' => Yii::t('app', 'Created At'),
'updated_at' => Yii::t('app', 'Updated At'),
];
}
public static function dropdown() {
$models = self::find()->all();
foreach ($models as $model) {
$dropdown[$model->theme_id] = $model->title;
}
return $dropdown;
}
public function getHeader() {
return $this->hasOne(FrontendHeader::className(), ['header_id' => 'header_id']);
}
public function getFooter() {
return $this->hasOne(FrontendFooter::className(), ['footer_id' => 'footer_id']);
}
}