| Current Path : /var/www/html/sprm/backend/models/ |
| Current File : /var/www/html/sprm/backend/models/ContentFaq.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_faq".
*
* @property int $faq_id
* @property int $faq_no
* @property string $faq_question
* @property string $faq_answer
* @property int $faq_status 0-Tidak Aktif,1-Aktif
* @property string $created_at
* @property int $created_by
* @property string $updated_at
* @property int $updated_by
*/
class ContentFaq extends \common\models\Dermaga {
/**
* @inheritdoc
*/
public static function tableName() {
return 'content_faq';
}
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'],
],
];
}
/**
* @inheritdoc
*/
public function rules() {
return [
[['faq_no', 'faq_status', 'created_by', 'updated_by'], 'integer'],
[['faq_question_my', 'faq_question_en', 'faq_answer_my', 'faq_answer_en'], 'string'],
[['faq_question_my', 'faq_answer_my', 'faq_status'], 'required'],
[['created_at', 'updated_at', 'faq_question_ch', 'faq_answer_ch'], 'safe'],
];
}
/**
* @inheritdoc
*/
public function attributeLabels() {
return [
'faq_id' => Yii::t('app', 'Faq ID'),
'faq_no' => Yii::t('app', 'Susunan'),
'faq_question_my' => Yii::t('app', 'Soalan'),
'faq_answer_my' => Yii::t('app', 'Jawapan'),
'faq_question_en' => Yii::t('app', 'Soalan (EN)'),
'faq_answer_en' => Yii::t('app', 'Jawapan (EN)'),
'faq_question_ch' => Yii::t('app', 'Soalan (CH)'),
'faq_answer_ch' => Yii::t('app', 'Jawapan (CH)'),
'faq_status' => Yii::t('app', 'Status'),
'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'),
];
}
}