| Current Path : /var/www/html/ekursus/backend/models/ |
| Current File : /var/www/html/ekursus/backend/models/ReportTable.php |
<?php
namespace backend\models;
use Yii;
/**
* This is the model class for table "report_table".
*
* @property integer $id_report_table
* @property integer $id_report_meta
* @property string $title_report_table
* @property string $table_name
* @property string $column_name
* @property string $sql_statement
* @property string $type_report
* @property string $created_by
* @property string $created_at
* @property string $updated_by
* @property string $updated_at
*/
class ReportTable extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'report_table';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_report_meta'], 'integer'],
[['column_name'], 'safe'],
[['id_report_meta','title_report_table'],'required'],
[['title_report_table', 'table_name', 'column_name', 'sql_statement', 'type_report', 'created_by', 'created_at', 'updated_by', 'updated_at','paginate','limit','is_sql'], 'string'],
['column_id','selectTable','skipOnEmpty' => false, 'skipOnError' => false],
['table_name', 'sourceType', 'skipOnEmpty' => false],
];
}
public function sourceType($attribute,$params, $validator){
if(empty($this->sql_statement) && $this->{$attribute} == NULL){
$this->addError($attribute, 'Sila isikan sumber data (table), atau gunakan sql');
return false;
// var_dump($this->{$attribute});die();
}
}
public function selectTable($attribute,$params, $validator){
if(!empty($this->table_name) && $this->{$attribute} == NULL )
$this->addError($attribute, 'Sila tentukan '.$attribute);
return false;
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id_report_table' => 'ID Laporan Table',
'id_report_meta' => 'ID Laporan Meta',
'title_report_table' => 'Tajuk Laporan Table',
'table_name' => 'Nama Table',
'column_name' => 'Nama Medan',
'sql_statement' => 'SQL',
'type_report' => 'Jenis Laporan',
'created_by' => 'Dicipta Oleh',
'created_at' => 'Dicipta Pada',
'updated_by' => 'Dikemaskini Oleh',
'updated_at' => 'Dikemaskini Pada',
'column_id' => 'ID Medan',
];
}
public function getReportMeta()
{
return $this->hasOne(ReportMeta::className(), ['id_report_meta' => 'id_report_meta']);
}
}