Last active
February 10, 2017 13:10
-
-
Save cebe/42dd6eb0bd26e06a04bcfdaf7d08c891 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use yii\behaviors\TimestampBehavior; | |
public function behaviors() | |
{ | |
return [ | |
'timestamp' => function() { | |
$b = new TimeStampBehavior(); | |
$b->attributes = [ | |
ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'], | |
ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'], | |
]; | |
// ... | |
return $b; | |
}, | |
]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment