| Current Path : /var/www/html/dosm/backend/models/ |
| Current File : /var/www/html/dosm/backend/models/LifeExpectancy.php |
<?php
namespace backend\models;
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 "life_expectancy".
*
*/
class LifeExpectancy extends \yii\db\ActiveRecord {
/**
* @inheritdoc
*/
public static function tableName() {
return 'life_expectancy1';
}
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 [
[['age_from ', 'age_until', 'jantina', 'ethnic', 'life_expectancy'], 'required'],
[['file_url'], 'required', 'on' => 'uploadfile'],
[['file_url'], 'file', 'extensions' => 'xlsx'],
];
}
public function attributeLabels() {
return [
'id' => Yii::t('app', 'ID'),
'age_from' => Yii::t('app', 'Age (from)'),
'age_until' => Yii::t('app', 'Age (until)'),
'jantina' => Yii::t('app', 'Gender'),
'ethnic' => Yii::t('app', 'Ethnic'),
'life_expectancy' => Yii::t('app', 'Life Of Expectancy'),
'created_at' => Yii::t('app', 'Created At'),
];
}
public static function GetHari($Placeholder = true, $Sorting = 'sort') {
if ($Placeholder)
$arr = ['' => 'Please Select Day'];
else
$arr = [];
foreach (range(1, 31) as $hari) {
$arr[$hari] = $hari;
}
return $arr;
}
public static function GetBulan($Placeholder = true, $Sorting = 'sort') {
if ($Placeholder)
$arr = ['' => 'Please Select Month'];
else
$arr = [];
foreach (range(1, 12) as $bulan) {
$arr[$bulan] = $bulan;
}
return $arr;
}
}