public function behaviors() {
return [
[
'class' => BlameableBehavior::className(),
'createdByAttribute' => 'created_by',
'updatedByAttribute' => 'updated_by',
],
'timestamp' => [
'class' => 'yii\behaviors\TimestampBehavior',
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'],
ActiveRecord::EVENT_BEFORE_UPDATE => ['updated'],
]
]
];
}
public function actionCreate() {
$model = new Status();
if ($model->load(Yii::$app->request->post())) {
// $model->created_by = Yii::$app->user->getId();
// $model->created_at = time();
// $model->updated_at = time();
$save = $model->save();
if ($save) {
return $this->redirect(['view', 'id' => $model->id]);
}
}
return $this->render('create', [
'model' => $model,
]);
}