| Current Path : /var/www/html/sprm/backend/models/ |
| Current File : /var/www/html/sprm/backend/models/ContentCalendar.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 "content_calendar".
*
* @property int $content_calendar_id
* @property string $content_calendar_date
* @property string $content_calendar_description
* @property string $created_at
* @property string $created_by
* @property string $updated_at
* @property string $updated_by
*/
class ContentCalendar extends \common\models\Dermaga {
public $nextmonthstart;
public $nextmonthend;
/**
* @inheritdoc
*/
public static function tableName() {
return 'content_calendar';
}
public function behaviors() {
return [
[
'class' => TimestampBehavior::className(),
'createdAtAttribute' => 'created_at',
'updatedAtAttribute' => 'updated_at',
'value' => new Expression('NOW()'),
],
[
'class' => BlameableBehavior::className(),
'createdByAttribute' => 'created_by',
'updatedByAttribute' => 'updated_by',
'value' => (!\Yii::$app->user->isGuest ? \Yii::$app->user->identity->staff->id : 0),
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => ['created_by'],
ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_by'],
],
],
'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 [
[['content_calendar_date', 'content_calendar_date_end', 'created_at', 'updated_at', 'content_calendar_description_en', 'content_calendar_description_ch'], 'safe'],
[['content_calendar_description'], 'string', 'max' => 1500],
[['content_calendar_location', 'content_calendar_category'], 'string', 'max' => 150],
[['active_fg', 'featured', 'content_calendar_pax'], 'integer'],
[['created_by', 'updated_by', 'content_calendar_time', 'content_calendar_time_end'], 'string', 'max' => 20],
];
}
/**
* @inheritdoc
*/
public function attributeLabels() {
return [
'content_calendar_id' => Yii::t('app', 'Calendar ID'),
'nextmonthstart' => Yii::t('app', 'Tarikh Dari'),
'nextmonthend' => Yii::t('app', 'Tarikh Hingga'),
'content_calendar_date' => Yii::t('app', 'Tarikh Mula'),
'content_calendar_date_end' => Yii::t('app', 'Tarikh Akhir'),
'content_calendar_description' => Yii::t('app', 'Penerangan'),
'content_calendar_description_en' => Yii::t('app', 'Penerangan (EN)'),
'content_calendar_description_ch' => Yii::t('app', 'Penerangan (CH)'),
'content_calendar_location' => Yii::t('app', 'Lokasi'),
'content_calendar_time' => Yii::t('app', 'Masa Mula'),
'content_calendar_pax' => Yii::t('app', 'Jumlah Peserta'),
'content_calendar_time_end' => Yii::t('app', 'Masa Akhir'),
'content_calendar_category' => Yii::t('app', 'Kategori'),
'active_fg' => Yii::t('app', 'Status'),
'featured' => Yii::t('app', 'Papar Di Portal?'),
'created_at' => Yii::t('app', 'Created At'),
'created_by' => Yii::t('app', 'Created By'),
'updated_at' => Yii::t('app', 'Updated At'),
'updated_by' => Yii::t('app', 'Updated By'),
];
}
public static function getList() {
$arr2 = [];
$arr = self::find()->where(['active_fg' => 1])->all();
foreach ($arr as $param) {
$arr2[$param->content_calendar_id] = $param->content_calendar_description;
}
return $arr2;
}
}