| Current Path : /var/www/html/aipa/backend/models/dashboard/ |
| Current File : /var/www/html/aipa/backend/models/dashboard/DmgDashboard.php |
<?php
namespace backend\models\dashboard;
use asinfotrack\yii2\audittrail\behaviors\AuditTrailBehavior;
use Yii;
/**
* This is the model class for table "dmg_dashboard".
*
* @property int $dmg_dashboard_id
* @property string $dmg_dashboard_title
* @property string $dmg_dashboard_subtitle
* @property string $dmg_dashboard_label
* @property string $dmg_dashboard_label_color
* @property string $dmg_dashboard_role
* @property string $dmg_dashboard_column
* @property string $dmg_dashboard_condition
* @property string $dmg_dashboard_chart_type
* @property string $dmg_dashboard_created_at
* @property string $dmg_dashboard_updated_at
*/
class DmgDashboard extends \yii\db\ActiveRecord
{
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 static function tableName()
{
return 'dmg_dashboard';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['dmg_dashboard_title', 'dmg_dashboard_label'], 'string', 'max' => 100],
[['dmg_dashboard_subtitle'], 'string', 'max' => 120],
[['dmg_dashboard_label_color'], 'string', 'max' => 15],
[['dmg_dashboard_role','dmg_dashboard_sum_column','dmg_dashboard_method','dmg_dashboard_grouping','dmg_dashboard_sql_panel_count','dmg_dashboard_sql_graph_count'], 'safe'],
[['dmg_dashboard_column','dmg_dashboard_table', 'dmg_dashboard_sum_column','dmg_dashboard_method','dmg_dashboard_condition', 'dmg_dashboard_chart_type','dmg_dashboard_created_at', 'dmg_dashboard_updated_at'], 'string', 'max' => 50],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
// 'dmg_dashboard_id' => Yii::t('app', 'Dmg Dashboard ID'),
'dmg_dashboard_title' => Yii::t('app', 'Title'),
'dmg_dashboard_subtitle' => Yii::t('app', 'Subtitle'),
'dmg_dashboard_label' => Yii::t('app', 'Label'),
'dmg_dashboard_label_color' => Yii::t('app', 'Label Color'),
'dmg_dashboard_role' => Yii::t('app', 'Role'),
'dmg_dashboard_column' => Yii::t('app', 'Column'),
'dmg_dashboard_condition' => Yii::t('app', 'Condition'),
'dmg_dashboard_chart_type' => Yii::t('app', 'Chart Type'),
'dmg_dashboard_created_at' => Yii::t('app', 'Created At'),
'dmg_dashboard_sql_graph_count' => Yii::t('app', 'Graph Count SQL'),
'dmg_dashboard_sql_panel_count' => Yii::t('app', 'Panel Count SQL'),
];
}
public function beforeSave($insert)
{
if (parent::beforeSave($insert)) {
if($insert)
{
// $this->survey_createdby = Yii::$app->user->id;
$this->dmg_dashboard_created_at = date('Y-m-d H:i:s');
}else{
$this->dmg_dashboard_updated_at = date('Y-m-d H:i:s');
// $this->survey_updatedby = Yii::$app->user->id;
}
return true;
} else {
return false;
}
}
}